static void Main(string[] args) { var nodeConfig = NodeConfiguration.GetDefault(); using (var core = new CrossStitchCore(nodeConfig)) { core.MessageBus.Subscribe <NodeAddedToClusterEvent>(s => s.WithTopic(NodeAddedToClusterEvent.EventName).Invoke(NodeAdded)); core.MessageBus.Subscribe <NodeRemovedFromClusterEvent>(s => s.WithTopic(NodeRemovedFromClusterEvent.EventName).Invoke(NodeRemoved)); core.MessageBus.Subscribe <ObjectReceivedEvent <NodeStatus> >(b => b .WithTopic(ReceivedEvent.ReceivedEventName(NodeStatus.BroadcastEvent)) .Invoke(ReceiveNodeStatus)); core.MessageBus.TimerSubscribe("tick", 1, b => b.Invoke(m => SendPing(core))); core.AddModule(new BackplaneModule(core)); var logger = new LoggerFactory().AddConsole(LogLevel.Debug).CreateLogger <Program>(); core.AddModule(new LoggingModule(core, logger)); core.Start(); core.Log.LogInformation("Started MASTER node {0}", core.NodeId); Console.ReadKey(); core.Log.LogInformation("Stopping node {0}", core.NodeId); core.Stop(); } }
static void Main(string[] args) { var config = NodeConfiguration.GetDefault(); using (var core = new CrossStitchCore(config)) { var stitchesConfiguration = StitchesConfiguration.GetDefault(); var stitches = new StitchesModule(core, stitchesConfiguration); core.AddModule(stitches); var logger = new LoggerFactory().AddConsole(LogLevel.Debug).CreateLogger <Program>(); core.AddModule(new LoggingModule(core, logger)); core.Start(); // First stitch is a Process, using STDIO StartProcessStitch(core, "Stdio", MessageChannelType.Stdio); // Second stitch is a Process using Pipes StartProcessStitch(core, "Pipes", MessageChannelType.Pipe); // Second stitch is a built -in class StartBuiltinStitch(core); Console.ReadKey(); core.Stop(); } }
static void Main(string[] args) { var nodeConfig = NodeConfiguration.GetDefault(); using (var core = new CrossStitchCore(nodeConfig)) { core.MessageBus.Subscribe <NodeAddedToClusterEvent>(l => l .WithChannelName(NodeAddedToClusterEvent.EventName) .Invoke(NodeAdded)); core.MessageBus.Subscribe <NodeRemovedFromClusterEvent>(l => l .WithChannelName(NodeRemovedFromClusterEvent.EventName) .Invoke(NodeRemoved)); core.AddModule(new BackplaneModule(core)); core.AddModule(new LoggingModule(core, Common.Logging.LogManager.GetLogger("CrossStitch"))); core.Start(); core.Log.LogInformation("Starting CLIENT node {0}", core.NodeId); Console.ReadKey(); core.Log.LogInformation("Stopping node {0}", core.NodeId); core.Stop(); } }
private static void Main(string[] args) { var config = NodeConfiguration.GetDefault(); using (var core = new CrossStitchCore(config)) { var stitchesConfiguration = StitchesConfiguration.GetDefault(); var stitches = new StitchesModule(core, stitchesConfiguration); core.AddModule(stitches); var logger = new LoggerFactory().AddConsole(LogLevel.Debug).CreateLogger <Program>(); core.AddModule(new LoggingModule(core, logger)); core.MessageBus.Subscribe <StitchHealthEvent>(b => b .WithTopic(StitchHealthEvent.TopicUnhealthy) .Invoke(e => core.Log.LogInformation("Stitch {0} is unhealthy", e.InstanceId))); core.MessageBus.Subscribe <StitchHealthEvent>(b => b .WithTopic(StitchHealthEvent.TopicReturnToHealth) .Invoke(e => core.Log.LogInformation("Stitch {0} is Healthy again", e.InstanceId))); core.Start(); StartBuiltinStitch(core); Console.ReadKey(); core.Stop(); } }
static void Main(string[] args) { var nodeConfig = NodeConfiguration.GetDefault(); nodeConfig.NodeId = "ServerA"; nodeConfig.NodeName = "StitchIntegration.ServerA"; using (var core = new CrossStitchCore(nodeConfig)) { Console.Title = core.Name; _testLog = new ModuleLog(core.MessageBus, "ServerA"); core.AddModule(new BackplaneModule(core)); core.AddModule(new StitchesModule(core)); var logger = new LoggerFactory().AddConsole(LogLevel.Debug).CreateLogger <Program>(); core.AddModule(new LoggingModule(core, logger)); core.Start(); _testLog.LogInformation("Waiting for ServerB"); // Wait until we get a node joined event with ServerB. Kick off the test and unsubscribe core.MessageBus.Subscribe <ClusterMemberEvent>(b => b .WithTopic(ClusterMemberEvent.EnteringEvent) .Invoke(m => TestStep1(core.MessageBus, m.NodeId, m.NetworkNodeId)) .OnThreadPool() .MaximumEvents(1)); Console.ReadKey(); core.Stop(); } }
static void Main(string[] args) { var nodeConfig = NodeConfiguration.GetDefault(); using (var core = new CrossStitchCore(nodeConfig)) { core.MessageBus.Subscribe <NodeAddedToClusterEvent>(s => s.WithChannelName(NodeAddedToClusterEvent.EventName).Invoke(NodeAdded)); core.MessageBus.Subscribe <NodeRemovedFromClusterEvent>(s => s.WithChannelName(NodeRemovedFromClusterEvent.EventName).Invoke(NodeRemoved)); core.MessageBus.Subscribe <ObjectReceivedEvent <NodeStatus> >(b => b .WithChannelName(ReceivedEvent.ReceivedEventName(NodeStatus.BroadcastEvent)) .Invoke(ReceiveNodeStatus)); core.MessageBus.TimerSubscribe(1, b => b.Invoke(m => SendPing(core))); core.AddModule(new BackplaneModule(core)); core.AddModule(new LoggingModule(core, Common.Logging.LogManager.GetLogger("CrossStitch"))); core.Start(); core.Log.LogInformation("Started MASTER node {0}", core.NodeId); Console.ReadKey(); core.Log.LogInformation("Stopping node {0}", core.NodeId); core.Stop(); } }
static void Main(string[] args) { var nodeConfig = NodeConfiguration.GetDefault(); using (var core = new CrossStitchCore(nodeConfig)) { core.MessageBus.Subscribe <NodeAddedToClusterEvent>(l => l .WithTopic(NodeAddedToClusterEvent.EventName) .Invoke(NodeAdded)); core.MessageBus.Subscribe <NodeRemovedFromClusterEvent>(l => l .WithTopic(NodeRemovedFromClusterEvent.EventName) .Invoke(NodeRemoved)); core.AddModule(new BackplaneModule(core)); var logger = new LoggerFactory().AddConsole(LogLevel.Debug).CreateLogger <Program>(); core.AddModule(new LoggingModule(core, logger)); core.Start(); core.Log.LogInformation("Starting CLIENT node {0}", core.NodeId); Console.ReadKey(); core.Log.LogInformation("Stopping node {0}", core.NodeId); core.Stop(); } }
static void Main(string[] args) { var nodeConfig = NodeConfiguration.GetDefault(); using (var core = new CrossStitchCore(nodeConfig)) { // Setup an in-memory data store var store = new InMemoryDataStorage(); core.AddModule(new DataModule(core.MessageBus, store)); // Backplane so we can cluster core.AddModule(new BackplaneModule(core)); // Stitches so we can host the stitch instances var stitchesConfig = StitchesConfiguration.GetDefault(); core.AddModule(new StitchesModule(core, stitchesConfig)); // Setup logging. var logger = new LoggerFactory().AddConsole(LogLevel.Debug).CreateLogger <Program>(); core.AddModule(new LoggingModule(core, logger)); // Create a stitch instance to run on startup var groupName = new StitchGroupName("PenPal.StitchA.1"); var packageFile = new PackageFile { Id = groupName.ToString(), GroupName = groupName, Adaptor = new InstanceAdaptorDetails { Type = AdaptorType.ProcessV1, Parameters = new Dictionary <string, string> { { Parameters.RunningDirectory, "." }, { Parameters.ExecutableArguments, "" }, { Parameters.ExecutableName, "PenPal.StitchA.exe" } } }, }; store.Save(packageFile, true); var stitch = new StitchInstance { Name = "StitchA", GroupName = groupName, OwnerNodeName = core.Name, OwnerNodeId = core.NodeId, State = InstanceStateType.Running }; store.Save(stitch, true); core.Start(); Console.ReadKey(); core.Stop(); } }
static void Main(string[] args) { var nodeConfig = NodeConfiguration.GetDefault(); using (var core = new CrossStitchCore(nodeConfig)) { var httpServer = new NancyHttpModule(core.MessageBus); core.AddModule(httpServer); var dataStorage = new InMemoryDataStorage(); var data = new DataModule(core.MessageBus, dataStorage); core.AddModule(data); var stitchesConfiguration = StitchesConfiguration.GetDefault(); var stitches = new StitchesModule(core, stitchesConfiguration); core.AddModule(stitches); var groupName = new StitchGroupName("HttpTest", "Stitch", "1"); var packageFile = new PackageFile { Id = groupName.ToString(), GroupName = groupName, Adaptor = new InstanceAdaptorDetails { Type = AdaptorType.ProcessV1, Parameters = new Dictionary <string, string> { { Parameters.RunningDirectory, "." }, { Parameters.ExecutableName, "HttpTest.Stitch.exe" }, //{ Parameters.ArgumentsFormat, "{ExecutableName} {CoreArgs} -- {CustomArgs}" }, //{ Parameters.ExecutableFormat, "dotnet" }, } }, }; dataStorage.Save(packageFile, true); var stitch = new StitchInstance { Name = "HttpTest.Stitch", GroupName = groupName, State = InstanceStateType.Running }; dataStorage.Save(stitch, true); var logger = new LoggerFactory().AddConsole(LogLevel.Debug).CreateLogger <Program>(); core.AddModule(new LoggingModule(core, logger)); core.Log.LogInformation("Started"); core.Start(); Console.ReadKey(); core.Stop(); } }
public CrossStitchServiceControl() { var nodeConfiguration = NodeConfiguration.GetDefault(); _core = new CrossStitchCore(nodeConfiguration); _core.AddModule(new LoggingModule(_core, Common.Logging.LogManager.GetLogger("CrossStitch"))); _core.AddModule(new NancyHttpModule(_core.MessageBus)); _core.AddModule(new DataModule(_core.MessageBus, new FolderDataStorage())); _core.AddModule(new StitchesModule(_core)); _core.AddModule(new BackplaneModule(_core)); }
public CrossStitchServiceControl() { var nodeConfiguration = NodeConfiguration.GetDefault(); _core = new CrossStitchCore(nodeConfiguration); var logger = new LoggerFactory().AddConsole(LogLevel.Debug).CreateLogger <Program>(); _core.AddModule(new LoggingModule(_core, logger)); _core.AddModule(new NancyHttpModule(_core.MessageBus)); _core.AddModule(new DataModule(_core.MessageBus, new FolderDataStorage())); _core.AddModule(new StitchesModule(_core)); _core.AddModule(new BackplaneModule(_core)); }
static void Main(string[] args) { var nodeConfig = NodeConfiguration.GetDefault(); using (var core = new CrossStitchCore(nodeConfig)) { var httpServer = new NancyHttpModule(core.MessageBus); core.AddModule(httpServer); var dataStorage = new InMemoryDataStorage(); var data = new DataModule(core.MessageBus, dataStorage); core.AddModule(data); var stitchesConfiguration = StitchesConfiguration.GetDefault(); var stitches = new StitchesModule(core, stitchesConfiguration); core.AddModule(stitches); var groupName = new StitchGroupName("HttpTest", "Stitch", "1"); var packageFile = new PackageFile { Id = groupName.ToString(), GroupName = groupName, Adaptor = new InstanceAdaptorDetails { Type = AdaptorType.ProcessV1, Parameters = new Dictionary <string, string> { { CrossStitch.Stitch.ProcessV1.Parameters.DirectoryPath, "." }, { CrossStitch.Stitch.ProcessV1.Parameters.ExecutableName, "HttpTest.Stitch.exe" } } }, }; dataStorage.Save(packageFile, true); var stitch = new StitchInstance { Name = "HttpTest.Stitch", GroupName = groupName, State = InstanceStateType.Running, LastHeartbeatReceived = 0 }; dataStorage.Save(stitch, true); core.AddModule(new LoggingModule(core, Common.Logging.LogManager.GetLogger("CrossStitch"))); core.Start(); Console.ReadKey(); core.Stop(); } }
static void Main(string[] args) { var config = NodeConfiguration.GetDefault(); using (var core = new CrossStitchCore(config)) { var dataStorage = new InMemoryDataStorage(); var groupName = new StitchGroupName("JsStitch", "Stitch", "1"); dataStorage.Save(new PackageFile { Id = groupName.ToString(), GroupName = groupName, Adaptor = new InstanceAdaptorDetails { Type = AdaptorType.ProcessV1, Parameters = new Dictionary <string, string> { { Parameters.RunningDirectory, "." }, { Parameters.ExecutableName, "JsStitch.Stitch.js" } } }, }, true); dataStorage.Save(new StitchInstance { Name = "JsStitch.Stitch", GroupName = groupName, State = InstanceStateType.Running }, true); var data = new DataModule(core.MessageBus, dataStorage); core.AddModule(data); var stitchesConfiguration = StitchesConfiguration.GetDefault(); var stitches = new StitchesModule(core, stitchesConfiguration); core.AddModule(stitches); var logger = new LoggerFactory().AddConsole(LogLevel.Debug).CreateLogger <Program>(); core.AddModule(new LoggingModule(core, logger)); core.Start(); Console.ReadKey(); core.Stop(); } }
static void Main(string[] args) { var nodeConfig = NodeConfiguration.GetDefault(); nodeConfig.NodeId = "ServerB"; nodeConfig.NodeName = "StitchIntegration.ServerB"; using (var core = new CrossStitchCore(nodeConfig)) { Console.Title = core.Name; core.AddModule(new BackplaneModule(core)); core.AddModule(new StitchesModule(core)); core.AddModule(new LoggingModule(core, Common.Logging.LogManager.GetLogger("CrossStitch"))); // This Node just runs. ServerA will generate and send commands to this node to produce changes core.Start(); Console.ReadKey(); core.Stop(); } }
static void Main(string[] args) { var nodeConfig = NodeConfiguration.GetDefault(); nodeConfig.NodeId = "ServerB"; nodeConfig.NodeName = "StitchIntegration.ServerB"; using (var core = new CrossStitchCore(nodeConfig)) { Console.Title = core.Name; core.AddModule(new BackplaneModule(core)); core.AddModule(new StitchesModule(core)); var logger = new LoggerFactory().AddConsole(LogLevel.Debug).CreateLogger <Program>(); core.AddModule(new LoggingModule(core, logger)); // This Node just runs. ServerA will generate and send commands to this node to produce changes core.Start(); Console.ReadKey(); core.Stop(); } }
static void Main(string[] args) { var config = NodeConfiguration.GetDefault(); using (var core = new CrossStitchCore(config)) { var dataStorage = new InMemoryDataStorage(); var pingGroup = new StitchGroupName("PingPong", "Ping", "1"); var pingPackage = new PackageFile { Id = pingGroup.ToString(), GroupName = pingGroup, Adaptor = new InstanceAdaptorDetails { Type = AdaptorType.ProcessV1, Parameters = new Dictionary <string, string> { { Parameters.RunningDirectory, "." }, { Parameters.ExecutableName, "PingPong.Ping.exe" } } }, }; var ping = new StitchInstance { Name = "PingPong.Ping", GroupName = pingGroup, State = InstanceStateType.Running }; var pongGroup = new StitchGroupName("PingPong", "Pong", "1"); var pongPackage = new PackageFile { Id = pongGroup.ToString(), GroupName = pongGroup, Adaptor = new InstanceAdaptorDetails { Type = AdaptorType.ProcessV1, Parameters = new Dictionary <string, string> { { Parameters.RunningDirectory, "." }, { Parameters.ExecutableName, "PingPong.Pong.exe" } } }, }; var pong = new StitchInstance { Name = "PingPong.Pong", GroupName = pongGroup, State = InstanceStateType.Running }; dataStorage.Save(pingPackage, true); dataStorage.Save(ping, true); dataStorage.Save(pongPackage, true); dataStorage.Save(pong, true); var data = new DataModule(core.MessageBus, dataStorage); core.AddModule(data); var stitchesConfiguration = StitchesConfiguration.GetDefault(); var stitches = new StitchesModule(core, stitchesConfiguration); core.AddModule(stitches); var logger = new LoggerFactory().AddConsole(LogLevel.Debug).CreateLogger <Program>(); core.AddModule(new LoggingModule(core, logger)); // TODO: We need a way to start for initialization to complete, either having Start // block or providing an Initialized event which waits for all modules to report // being initialized core.Start(); Console.ReadKey(); core.Stop(); } }
static void Main(string[] args) { var config = NodeConfiguration.GetDefault(); using (var core = new CrossStitchCore(config)) { var stitchesConfiguration = StitchesConfiguration.GetDefault(); var stitches = new StitchesModule(core, stitchesConfiguration); core.AddModule(stitches); var log = Common.Logging.LogManager.GetLogger("CrossStitch"); var logging = new LoggingModule(core, log); core.AddModule(logging); core.Start(); // First stitch is a processV1 var group1 = new StitchGroupName("StitchStart", "Client", "1"); var packageResult1 = core.MessageBus.Request <DataRequest <PackageFile>, DataResponse <PackageFile> >(DataRequest <PackageFile> .Save(new PackageFile { Id = group1.ToString(), GroupName = group1, Adaptor = new InstanceAdaptorDetails { Type = AdaptorType.ProcessV1, Parameters = new Dictionary <string, string> { { Parameters.DirectoryPath, "." }, { Parameters.ExecutableName, "StitchStart.Client.exe" } }, RequiresPackageUnzip = false } }, true)); var createResult1 = core.MessageBus.Request <LocalCreateInstanceRequest, LocalCreateInstanceResponse>(new LocalCreateInstanceRequest { Name = "StitchStart.Client", GroupName = group1, NumberOfInstances = 1, }); core.MessageBus.Request <InstanceRequest, InstanceResponse>(InstanceRequest.ChannelStart, new InstanceRequest { Id = createResult1.CreatedIds.FirstOrDefault() }); // Second stitch is a built-in class var group2 = new StitchGroupName("StitchStart", "BuiltIn", "1"); var packageResult2 = core.MessageBus.Request <DataRequest <PackageFile>, DataResponse <PackageFile> >(DataRequest <PackageFile> .Save(new PackageFile { Id = group2.ToString(), GroupName = group2, Adaptor = new InstanceAdaptorDetails { Type = AdaptorType.BuildInClassV1, Parameters = new Dictionary <string, string> { { CrossStitch.Stitch.BuiltInClassV1.Parameters.TypeName, typeof(StitchStartBuiltInStitch).AssemblyQualifiedName } } }, }, true)); var createResult2 = core.MessageBus.Request <LocalCreateInstanceRequest, LocalCreateInstanceResponse>(new LocalCreateInstanceRequest { Name = "StitchStart.BuiltIn", GroupName = group2, NumberOfInstances = 1 }); core.MessageBus.Request <InstanceRequest, InstanceResponse>(InstanceRequest.ChannelStart, new InstanceRequest { Id = createResult2.CreatedIds.FirstOrDefault() }); Console.ReadKey(); core.Stop(); } }