Esempio n. 1
0
 public Creature(GameUniverse g) : base(g)
 {
     //
     CurrentHealth = 3;
     //
     StatusTracker = g.CreatureRules.CreateStatusTracker(this);
 }
Esempio n. 2
0
 [SetUp] public void Initialize()
 {
     StatusConverter <TestStatus, int> .Convert = x => (int)x;
     rules   = new StatusSystem <TestObj, TestStatus>();
     testObj = new TestObj();
     tracker = rules.CreateStatusTracker(testObj);
 }
Esempio n. 3
0
        internal static void SparkContextSample()
        {
            Console.WriteLine(SparkCLRSamples.SparkContext.Version);
            Console.WriteLine(SparkCLRSamples.SparkContext.SparkUser);
            Console.WriteLine(SparkCLRSamples.SparkContext.StartTime);
            Console.WriteLine(SparkCLRSamples.SparkContext.DefaultParallelism);
            Console.WriteLine(SparkCLRSamples.SparkContext.DefaultMinPartitions);

            StatusTracker StatusTracker = SparkCLRSamples.SparkContext.StatusTracker;

            //var file = Path.GetTempFileName();
            //File.WriteAllText(file, "Sample");
            //SparkCLRSamples.SparkContext.AddFile(file);

            var dir = Path.GetTempPath();

            SparkCLRSamples.SparkContext.SetCheckpointDir(dir);

            SparkCLRSamples.SparkContext.SetLogLevel("DEBUG");
            //SparkCLRSamples.SparkContext.SetJobGroup("SampleGroupId", "Sample Description");
            SparkCLRSamples.SparkContext.SetLocalProperty("SampleKey", "SampleValue");

            Console.WriteLine(SparkCLRSamples.SparkContext.GetLocalProperty("SampleKey"));
            SparkCLRSamples.SparkContext.CancelJobGroup("SampleGroupId");
            SparkCLRSamples.SparkContext.CancelAllJobs();
        }
Esempio n. 4
0
        public void TestSparkStageInfo()
        {
            const int    stageId           = 65536;
            const int    currentAttemptId  = 1;
            long         submissionTime    = DateTime.Now.Millisecond;
            const string name              = "name-1";
            const int    numTasks          = 20;
            const int    numActiveTasks    = 10;
            const int    numCompletedTasks = 5;
            const int    numFailedTasks    = 0;

            // arrange
            Mock <IStatusTrackerProxy> statusTrackerProxy = new Mock <IStatusTrackerProxy>();
            var expectedStageInfo = new SparkStageInfo(stageId, currentAttemptId, submissionTime, name, numTasks, numActiveTasks, numCompletedTasks, numFailedTasks);

            statusTrackerProxy.Setup(m => m.GetStageInfo(It.IsAny <int>())).Returns(expectedStageInfo);
            var tracker = new StatusTracker(statusTrackerProxy.Object);

            // act
            SparkStageInfo stageInfo = tracker.GetStageInfo(stageId);

            // assert
            Assert.IsNotNull(stageInfo);
            Assert.AreEqual(stageId, stageInfo.StageId);
            Assert.AreEqual(currentAttemptId, stageInfo.CurrentAttemptId);
            Assert.AreEqual(submissionTime, stageInfo.SubmissionTime);
            Assert.AreEqual(name, stageInfo.Name);
            Assert.AreEqual(numTasks, stageInfo.NumTasks);
            Assert.AreEqual(numActiveTasks, stageInfo.NumActiveTasks);
            Assert.AreEqual(numCompletedTasks, stageInfo.NumCompletedTasks);
            Assert.AreEqual(numFailedTasks, stageInfo.NumFailedTasks);
        }
Esempio n. 5
0
    // Start is called before the first frame update
    void Awake()
    {
        GameManager gm = GameManager.Instance;

        DontDestroyOnLoad(gm);
        DialogController dc = DialogController.Instance;
        StatusTracker    st = StatusTracker.Instance;
    }
Esempio n. 6
0
        public void TestGetRoadStatus_When_InValidRoadId_Then_Return_Expected_InformativeError(string expectedFailureMessage)
        {
            base.SetupForInvalidRoad();
            var statusTracker = new StatusTracker(_tflRepository.Object);

            //Act
            var roadInfo = statusTracker.GetRoadStatus(It.IsAny <string>());

            //Assert
            Assert.AreEqual(expectedFailureMessage, roadInfo?.FailureMessage);
        }
Esempio n. 7
0
        public void TestGetRoadStatus_When_ValidRoadId_Then_Return_Expected_StatusSeverityDescription(string expectedRoadStatusDescription)
        {
            //Arrange
            base.SetupForValidRoad();
            var statusTracker = new StatusTracker(_tflRepository.Object);

            //Act
            var roadInfo = statusTracker.GetRoadStatus(It.IsAny <string>());

            //Assert
            Assert.AreEqual(expectedRoadStatusDescription, roadInfo?.StatusSeverityDescription);
        }
Esempio n. 8
0
        public void TestGetRoadStatus_When_ValidRoadId_Then_Return_Expected_DisplayName(string expectedDisplayName)
        {
            //Arrange
            base.SetupForValidRoad();
            var statusTracker = new StatusTracker(_tflRepository.Object);

            //Act
            var roadInfo = statusTracker.GetRoadStatus(It.IsAny <string>());

            //Assert
            Assert.AreEqual(expectedDisplayName, roadInfo?.DisplayName);
        }
Esempio n. 9
0
        public RipperService(RipperNotificator notificator, Persister <RipperSettings> settings, ILogger logger)
        {
            _notificator = notificator;
            _settings    = settings;
            _logger      = logger;
            _tagSource   = new MusicBrainzTagSource(new MusicBrainzApi("http://musicbrainz.org"), new CoverArtArchiveApi("http://coverartarchive.org"));
            _tracker     = new StatusTracker();

            _tracker.OnStatusUpdated   += s => _notificator.UpdateStatus(s);
            _tracker.OnRippingProgress += (t, p) => _notificator.UpdateProgress(t, p);

            _tracker.OnDiscInserted  += d => IdentifyAlbum(d, true);
            _tracker.OnAlbumSelected += (d, a) => StartRipping(d, a);
        }
Esempio n. 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SimpleBingCommercePusher"/> class.
        /// </summary>
        /// <param name="config">The pusher configurations object</param>
        /// <param name="checkpoint">The checkpoint to poll the data since if it's valid.</param>
        /// <param name="serializer">(Optional): Explicit serialier to be used.</param>
        public SimpleBingCommercePusher(BingCommerceConfig config, IDataCheckpoint checkpoint, IPushSerializer <IDictionary <string, object> > serializer = null)
        {
            var sdkClient = new BingCommerceIngestion(new TokenCredentials(config.AccessToken));
            var logger    = new RequestLogger(config.RequestLogLocation, config.RequestLog);

            this.config             = config;
            this.client             = new IngestionClient(sdkClient, config.TenantId, config.IndexId, config.RetryCount, logger);
            this.tracker            = new StatusTracker(this.client, config.TrackingInterval, logger);
            this.taskManager        = new TaskManager(config.MaxConcurrentRequests);
            this.checkpointAcceptor = new CheckpointAcceptor(checkpoint);
            this.Serializer         = serializer ?? new FormatSerializer(config.PushFormat);

            log.Debug("Successfully created the Simple Bing Commerce Pusher with the provided access token.");
        }
Esempio n. 11
0
        public StatusPanel()
        {
            var panel = downPanel();

            Content    = panel;
            Loaded    += initialize;
            statusGrid = new QDataTableGrid(loadStatusRow, unloadStatusRow);
            var systemStatus = new DockableContent {
                Name = "Status", Title = "System Status", Content = statusGrid
            };

            panel.Children.Add(systemStatus);
            LogC.info("starting status tracker");
            statusTracker = new StatusTracker(this, StatusTracker.allLiveSystems());
        }
Esempio n. 12
0
        public void TestStatusTrackerMethods()
        {
            // arrange
            Mock <IStatusTrackerProxy> statusTrackerProxy = new Mock <IStatusTrackerProxy>();

            // GetJobIdsForGroup
            const string jobGroup = "group-0";

            int[] expectedJobIds = new[] { 1001, 1002, 1003 };
            statusTrackerProxy.Setup(m => m.GetJobIdsForGroup(It.IsAny <string>())).Returns(expectedJobIds);

            // GetActiveJobsIds
            int[] expectedActiveJobIds = new[] { 1001, 1003 };
            statusTrackerProxy.Setup(m => m.GetActiveJobsIds()).Returns(expectedActiveJobIds);

            // GetActiveStageIds
            int[] expectedActiveStageIds = new[] { 666, 667, 668 };
            statusTrackerProxy.Setup(m => m.GetActiveStageIds()).Returns(expectedActiveStageIds);

            var tracker = new StatusTracker(statusTrackerProxy.Object);

            // act
            var jobIds         = tracker.GetJobIdsForGroup(jobGroup);
            var activeJobIds   = tracker.GetActiveJobsIds();
            var activeStageIds = tracker.GetActiveStageIds();

            // assert
            // GetJobIdsForGroup
            Assert.IsNotNull(jobIds);
            Assert.AreEqual(expectedJobIds, jobIds);

            // GetActiveJobsIds
            Assert.IsNotNull(activeJobIds);
            Assert.AreEqual(expectedActiveJobIds, activeJobIds);

            // GetActiveStageIds
            Assert.IsNotNull(activeStageIds);
            Assert.AreEqual(expectedActiveStageIds, activeStageIds);
        }
Esempio n. 13
0
        public void TestSparkJobInfo()
        {
            const int jobId = 65536;

            int[]        stageIds = new[] { 100, 102, 104 };
            const string status   = "RUNNING";

            // arrange
            Mock <IStatusTrackerProxy> statusTrackerProxy = new Mock <IStatusTrackerProxy>();
            var expectedJobInfo = new SparkJobInfo(jobId, stageIds, status);

            statusTrackerProxy.Setup(m => m.GetJobInfo(It.IsAny <int>())).Returns(expectedJobInfo);
            var tracker = new StatusTracker(statusTrackerProxy.Object);

            // act
            SparkJobInfo jobInfo = tracker.GetJobInfo(jobId);

            // assert
            Assert.IsNotNull(jobInfo);
            Assert.AreEqual(jobId, jobInfo.JobId);
            Assert.AreEqual(stageIds, jobInfo.StageIds);
            Assert.AreEqual(status, jobInfo.Status);
        }
Esempio n. 14
0
        public void TestSparkJobInfo(
            [Values(JobExecutionStatus.Failed, JobExecutionStatus.Running, JobExecutionStatus.Succeeded, JobExecutionStatus.Unknown)] JobExecutionStatus status
            )
        {
            const int jobId = 65536;

            int[] stageIds = new[] { 100, 102, 104 };

            // arrange
            Mock <IStatusTrackerProxy> statusTrackerProxy = new Mock <IStatusTrackerProxy>();
            var expectedJobInfo = new SparkJobInfo(jobId, stageIds, status);

            statusTrackerProxy.Setup(m => m.GetJobInfo(It.IsAny <int>())).Returns(expectedJobInfo);
            var tracker = new StatusTracker(statusTrackerProxy.Object);

            // act
            SparkJobInfo jobInfo = tracker.GetJobInfo(jobId);

            // assert
            Assert.IsNotNull(jobInfo);
            Assert.AreEqual(jobId, jobInfo.JobId);
            Assert.AreEqual(stageIds, jobInfo.StageIds);
            Assert.AreEqual(status, jobInfo.Status);
        }
Esempio n. 15
0
        public async Task TestStatusTracker()
        {
            var updateId = "123";

            var            failAfter   = 2;
            AutoResetEvent signal      = new AutoResetEvent(false);
            var            interceptor = new TestDelegatingHandler((request) =>
            {
                if (request.RequestUri.ToString().Contains("/status/"))
                {
                    // Artificial response for the PushUpdateStatus request.
                    PushUpdateStatusResponse status = new PushUpdateStatusResponse()
                    {
                        UpdateId = updateId,
                        Status   = (failAfter-- > 0) ? "InProgress" : "PartiallySucceeded",
                        Records  = new List <ResponseRecordStatus>()
                        {
                            new ResponseRecordStatus()
                            {
                                RecordId = "1", Status = "Succeeded"
                            },
                            new ResponseRecordStatus()
                            {
                                RecordId = "2", Status = "Failed", ErrorMessage = "error message"
                            }
                        }
                    };

                    var response     = new HttpResponseMessage(System.Net.HttpStatusCode.OK);
                    response.Content = new StringContent(JsonConvert.SerializeObject(status));
                    if (status.Status != "InProgress")
                    {
                        signal.Set();
                    }

                    return(response);
                }
                else
                {
                    // Artificial response for the GetIndex request.
                    var index = new IndexResponse()
                    {
                        Indexes = new List <ResponseIndex>()
                        {
                            new ResponseIndex
                            {
                                Id     = "index",
                                Fields = new List <IndexField>()
                                {
                                    new IndexField()
                                    {
                                        Name = "notid", Type = IndexFieldType.Title
                                    },
                                    new IndexField()
                                    {
                                        Name = "myid", Type = IndexFieldType.ProductId
                                    },
                                    new IndexField()
                                    {
                                        Name = "alsonotid", Type = IndexFieldType.Description
                                    }
                                }
                            }
                        }
                    };

                    var response     = new HttpResponseMessage(System.Net.HttpStatusCode.OK);
                    response.Content = new StringContent(JsonConvert.SerializeObject(index));
                    return(response);
                }
            });

            try
            {
                var ingestion = new BingCommerceIngestion(new TokenCredentials("test"), interceptor);
                var logger    = new RequestLogger(".\\log", RequestLogLevel.DeadletterOnly);
                var client    = new IngestionClient(ingestion, "tenant", "index", 1, logger);
                var tracker   = new StatusTracker(client, TimeSpan.FromSeconds(1), logger);

                tracker.Start();
                tracker.Add(updateId, new List <Dictionary <string, object> >()
                {
                    new Dictionary <string, object>()
                    {
                        { "myid", "1" }, { "notid", "something" }, { "stillnotid", "still something" }
                    },
                    new Dictionary <string, object>()
                    {
                        { "myid", "2" }, { "notid", "something else" }, { "stillnotid", "still something else" }
                    },
                });

                Assert.AreEqual(0, Directory.GetFiles(".\\log\\deadletter").Length, "Expecting no files to be in the deadletter directory");

                signal.WaitOne(TimeSpan.FromSeconds(10));

                // Adding an extra 2 seconds delay for two reasons:
                //  1. Make sure to give the tracker the chance to process the api response and logging the failure.
                //  2. Make sure that the failure would be processed only once (the next event would skip it).
                await Task.Delay(TimeSpan.FromSeconds(2));

                Assert.AreEqual(1, Directory.GetFiles(".\\log\\deadletter").Length, "Expecting one file to be in the deadletter directory");

                Assert.AreEqual(1, JArray.Parse(File.ReadAllText(Directory.EnumerateFiles(".\\log\\deadletter").First())).Count);
            }
            finally
            {
                Directory.Delete(".\\log", true);
            }
        }
Esempio n. 16
0
 void kill()
 {
     clearRestarts();
     O.each(statusGrid.selectedRows(), row => StatusTracker.kill((int)row["id"]));
 }
Esempio n. 17
0
 public void GivenAnInstanceOfStatusTracker()
 {
     _statusTracker = new StatusTracker();
 }
Esempio n. 18
0
 //Checks for other instance
 //Methods
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
Esempio n. 19
0
 private void SerializeCallback(System.IO.BinaryWriter writer, StatusInstance <TestObj> instance, StatusTracker <TestObj> tracker)
 {
     writer.Write("hello");
     writer.Write(true);
 }