Exemplo n.º 1
0
        /// <summary>
        /// Returns the number of tasks that failed for reasons other than preemption
        /// </summary>
        /// <param name="schedulerJob"></param>
        /// <returns></returns>
        private int GetNonPreemptedFailedTaskCount(IScheduler scheduler, ISchedulerJob schedulerJob)
        {
            int ret = 0;

            try
            {
                // Filter by failed tasks that failed due to preemption
                IFilterCollection fc = scheduler.CreateFilterCollection();
                fc.Add(FilterOperator.NotEqual, TaskPropertyIds.FailureReason, FailureReason.Preempted);
                fc.Add(FilterOperator.Equal, TaskPropertyIds.State, TaskState.Failed);

                // Only return the task Ids
                IPropertyIdCollection propIds = new PropertyIdCollection();
                propIds.AddPropertyId(TaskPropertyIds.TaskId);

                using (ISchedulerRowSet failedTasks = schedulerJob.OpenTaskRowSet(propIds, fc, null, true))
                {
                    ret = failedTasks.GetCount();
                }
            }

            catch (Exception ex)
            {
                TraceHelper.TraceEvent(this.sessionid, TraceEventType.Warning, "[JobMonitorEntry] Failed to get non-preempted failed task count : {0}", ex);
            }

            return(ret);
        }
Exemplo n.º 2
0
        public Dictionary <int, ISchedulerJob> GetJobs(JobState state)
        {
            IFilterCollection jobFilters = hpcScheduler.CreateFilterCollection();

            jobFilters.Add(FilterOperator.Equal, PropId.Job_State, state);
            ISchedulerCollection            jobs    = hpcScheduler.GetJobList(jobFilters, null);
            Dictionary <int, ISchedulerJob> jobDict = new Dictionary <int, ISchedulerJob>();

            foreach (ISchedulerJob job in jobs)
            {
                updateMinimum(job);

                if (!jobDict.ContainsKey(job.Id))
                {
                    jobDict[job.Id] = job;
                }
            }

            if (state == JobState.Running)  //|| state == JobState.Finished || state == JobState.Finishing )
            {
                lastMinStartTime = tempMinStartTime;
            }

            return(jobDict);
        }
Exemplo n.º 3
0
        public Dictionary <int, ISchedulerJob> GetJobs(DateTime lastDate)
        {
            IFilterCollection jobFilters = hpcScheduler.CreateFilterCollection();

            jobFilters.Add(FilterOperator.GreaterThanOrEqual, PropId.Job_StartTime, lastDate);
            ISchedulerCollection            jobs    = hpcScheduler.GetJobList(jobFilters, null);
            Dictionary <int, ISchedulerJob> jobDict = new Dictionary <int, ISchedulerJob>();

            foreach (ISchedulerJob job in jobs)
            {
                if (job.State == JobState.Running)
                {
                    updateMinimum(job);
                }
                else
                {
                    continue;
                }


                if (!jobDict.ContainsKey(job.Id))
                {
                    jobDict[job.Id] = job;
                }
            }

            lastMinStartTime = tempMinStartTime;
            lastGetJobsRun   = jobs;

            return(jobDict);
        }
Exemplo n.º 4
0
        private T Create <T>(IFilterCollection filterCollection)
            where T : ICommand, ISetFilters, new()
        {
            var command = Command <ICommandInputData> .CreateCommand <T>(filterCollection);

            return(command);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets the EntityInstances for SalesOrderHeader Entity and
        /// populate the DataTable
        /// </summary>
        /// <returns>Populated DataTable</returns>
        public DataTable GetSalesOrderHeaderItems()
        {
            if ((entitySalesOrderHeader != null) &&
                (lobInstance != null))
            {
                // Get the default filters
                IFilterCollection filters =
                    entitySalesOrderHeader.GetMethodInstance(
                        SalesOrderHeaderFinderName,
                        MethodInstanceType.Finder).GetFilters();

                // Execute the FindFiltered method online.
                IEntityInstanceEnumerator enumerator =
                    entitySalesOrderHeader.FindFiltered(
                        filters,
                        SalesOrderHeaderFinderName,
                        lobInstance,
                        OperationMode.Online);

                SalesOrderTable = null;
                SalesOrderTable = catalog.Helper.CreateDataTable(enumerator);
            }

            return(SalesOrderTable);
        }
Exemplo n.º 6
0
 public void TestInitialize()
 {
     _serviceSettings        = Substitute.For <IServiceSettings>();
     _splitTunnelClient      = Substitute.For <ISplitTunnelClient>();
     _appFilter              = Substitute.For <IFilterCollection>();
     _reverseSplitTunnelApps = new IncludeModeApps(_serviceSettings);
     _permittedRemoteAddress = Substitute.For <IFilterCollection>();
 }
Exemplo n.º 7
0
        public static T CreateCommand <T>(IFilterCollection filterCollection)
            where T : ICommand, ISetFilters, new()
        {
            var command = new T();

            command.SetFilters(filterCollection);
            return(command);
        }
Exemplo n.º 8
0
        private List <ISchedulerTask> GetFailedTasks(ISchedulerJob job)
        {
            IFilterCollection filters = _scheduler.CreateFilterCollection();

            filters.Add(FilterOperator.Equal, PropId.Task_State, TaskState.Failed);
            var failedTasks = job.GetTaskList(filters, null, true).Cast <ISchedulerTask>().ToList();

            return(failedTasks);
        }
Exemplo n.º 9
0
        static ISchedulerCollection getTasksFilterByEndTime(ISchedulerJob job)
        {
            ISchedulerCollection tasks;
            IFilterCollection    filters = scheduler.CreateFilterCollection();

            filters.Add(FilterOperator.GreaterThanOrEqual, PropId.Task_EndTime, iterationStartTime);
            tasks = job.GetTaskList(filters, null, true);

            return(tasks);
        }
Exemplo n.º 10
0
        /// <summary>
        /// retrieves node list based on the specified filters
        /// </summary>
        /// <param name="filters"></param>
        /// <param name="sorts"></param>
        /// <returns></returns>
        public List <ISchedulerNode> GetNodeList(IFilterCollection filters, ISortCollection sorts)
        {
            List <ISchedulerNode> nodes = new List <ISchedulerNode>();

            foreach (ISchedulerNode schedulerNode in _scheduler.GetNodeList(filters, sorts))
            {
                nodes.Add(schedulerNode);
            }

            return(nodes);
        }
Exemplo n.º 11
0
        /// <summary>
        /// retrieves a list of jobs based on the specified filters
        /// </summary>
        /// <returns></returns>
        public List <ISchedulerJob> GetJobList(IFilterCollection filters, ISortCollection sorts)
        {
            List <ISchedulerJob> jobs = new List <ISchedulerJob>();

            foreach (ISchedulerJob schedulerJob in _scheduler.GetNodeList(filters, sorts))
            {
                jobs.Add(schedulerJob);
            }

            return(jobs);
        }
Exemplo n.º 12
0
 public SplitTunnel(
     IServiceSettings serviceSettings,
     ISplitTunnelClient splitTunnelClient,
     IncludeModeApps reverseSplitTunnelApps,
     IFilterCollection appFilter,
     IFilterCollection permittedRemoteAddress)
 {
     _permittedRemoteAddress = permittedRemoteAddress;
     _appFilter              = appFilter;
     _splitTunnelClient      = splitTunnelClient;
     _reverseSplitTunnelApps = reverseSplitTunnelApps;
     _serviceSettings        = serviceSettings;
 }
Exemplo n.º 13
0
        /// <summary>
        /// GetFailedAndCanceledTasks
        /// </summary>
        /// <param name="scheduler">scheduler</param>
        /// <param name="job">job</param>
        /// <returns>ISchedulerTask</returns>
        public static List <ISchedulerTask> GetFailedAndCanceledTasks(IScheduler scheduler, ISchedulerJob job)
        {
            IFilterCollection filters = scheduler.CreateFilterCollection();

            filters.Add(FilterOperator.Equal, PropId.Task_State, TaskState.Failed);
            var failedTasks = job.GetTaskList(filters, null, true).Cast <ISchedulerTask>().ToList();

            filters = scheduler.CreateFilterCollection();
            filters.Add(FilterOperator.Equal, PropId.Task_State, TaskState.Canceled);
            var canceledTasks = job.GetTaskList(filters, null, true).Cast <ISchedulerTask>().ToList();

            return(failedTasks.Append(canceledTasks).ToList());
        }
Exemplo n.º 14
0
        static void createLogData()
        {
            IFilterCollection jobFilters = scheduler.CreateFilterCollection();

            jobFilters.Add(FilterOperator.GreaterThanOrEqual, PropId.Job_StartTime, jobMinStartDate);

            ISchedulerCollection jobs = scheduler.GetJobList(jobFilters, null);            //getJobs  (jobFilters);

            DateTime now = DateTime.Now;

            foreach (ISchedulerJob job in  jobs)
            {
                generateTaskLogLines(now, job, getTasks(job, TaskState.Failed));
                generateTaskLogLines(now, job, getTasks(job, TaskState.Finished));
            }
        }
Exemplo n.º 15
0
 internal SplitTunnel(
     bool enabled,
     bool reverseEnabled,
     IServiceSettings serviceSettings,
     ISplitTunnelClient splitTunnelClient,
     IncludeModeApps reverseSplitTunnelApps,
     IFilterCollection appFilter,
     IFilterCollection permittedRemoteAddress) :
     this(serviceSettings,
          splitTunnelClient,
          reverseSplitTunnelApps,
          appFilter,
          permittedRemoteAddress)
 {
     _enabled        = enabled;
     _reverseEnabled = reverseEnabled;
 }
Exemplo n.º 16
0
        public static bool TryGetJob(IScheduler scheduler, string username, int jobID, out ISchedulerJob job)
        {
            IFilterCollection filter = scheduler.CreateFilterCollection();

            filter.Add(FilterOperator.Equal, PropId.Job_UserName, username);

            if (scheduler.GetJobIdList(filter, null).Contains(jobID))
            {
                job = scheduler.OpenJob(jobID);
            }
            else
            {
                job = null;
            }

            return(job != null);
        }
Exemplo n.º 17
0
        static void getMinimumStartDate()
        {
            taskMaxEndDate   = new DateTime(1970, 1, 1);
            tempMaxEndDate   = new DateTime(1970, 1, 1);
            jobMinStartDate  = new DateTime(3000, 1, 1);
            tempMinStartDate = new DateTime(3000, 1, 1);

            ISchedulerCollection jobs;



            while (true)
            {
                IFilterCollection jobFilter = scheduler.CreateFilterCollection();
                jobFilter.Add(FilterOperator.Equal, PropId.Job_State, JobState.Running);
                jobs = scheduler.GetJobList(jobFilter, null);

                foreach (ISchedulerJob job in jobs)
                {
                    tempMinStartDate = job.StartTime < tempMinStartDate ? job.StartTime : tempMinStartDate;

                    ISchedulerCollection tasks = getTasks(job, TaskState.Finished);
                    foreach (ISchedulerTask task in tasks)
                    {
                        tempMaxEndDate = task.EndTime > tempMaxEndDate ? task.EndTime : tempMaxEndDate;
                    }
                }

                if (jobs.Count > 0)
                {
                    info("There are now running jobs. Sleeping (" + runningJobPollDuration + ")");
                    return;
                }
                else
                {
                    warn("There are no running jobs. Sleeping (" + runningJobPollDuration + ")");
                }
                Thread.Sleep(runningJobPollDuration * 1000);
            }

            taskMaxEndDate  = tempMaxEndDate;
            jobMinStartDate = tempMinStartDate;
        }
Exemplo n.º 18
0
        //This method uses a Wildcard Filter on the Read All Operation to return partial matches
        public List <BdcSupplier> GetSuppliersByName(string supplierName)
        {
            //Get the BDC entity
            IEntity entity = catalog.GetEntity(Constants.BdcContactsEntityNameSpace, "BdcSupplier");

            //Get all Filters for the entity
            IFilterCollection filters = entity.GetMethodInstance("ReadList2", MethodInstanceType.Finder).GetFilters();

            //Set Filter value)
            if (!string.IsNullOrEmpty(supplierName))
            {
                WildcardFilter filter = (WildcardFilter)filters[0];
                filter.Value = supplierName;
            }

            //Get Filtered ITems
            IEntityInstanceEnumerator enumerator = entity.FindFiltered(filters, "ReadList2", contactsLobSystemInstance);

            return(new DataMapper <BdcSupplier>(entity.Catalog.Helper.CreateDataTable(enumerator)).Collection);
        }
Exemplo n.º 19
0
        //This method uses a Wildcard Filter on the Read All Operation to return partial matches
        public List <BdcMachine> GetMachinesByModelNumber(string modelNumber)
        {
            //Get the BDC entity
            IEntity entity = catalog.GetEntity(Constants.BdcEntityNameSpace, "Machines");

            //Get all Filters for the entity
            IFilterCollection filters = entity.GetDefaultFinderFilters();

            //Set Filter value
            if (!string.IsNullOrEmpty(modelNumber))
            {
                WildcardFilter filter = (WildcardFilter)filters[0];
                filter.Value = modelNumber;
            }

            //Get Filtered ITems
            IEntityInstanceEnumerator enumerator = entity.FindFiltered(filters, partsManagementLobSystemInstance);

            return(new DataMapper <BdcMachine>(entity.Catalog.Helper.CreateDataTable(enumerator)).Collection);
        }
Exemplo n.º 20
0
        static void ExecuteBcsEctMethods(string siteUrl)
        {
            using (SPSite site = new SPSite(siteUrl))
            {
                using (new SPServiceContextScope(SPServiceContext.GetContext(site)))
                {
                    BdcServiceApplicationProxy    proxy  = (BdcServiceApplicationProxy)SPServiceContext.Current.GetDefaultProxy(typeof(BdcServiceApplicationProxy));
                    DatabaseBackedMetadataCatalog model  = proxy.GetDatabaseBackedMetadataCatalog();
                    IEntity            entity            = model.GetEntity("EmployeeEntityModel.BdcModel1", "Entity1");     // Namespace, Entity name
                    ILobSystemInstance lobSystemInstance = entity.GetLobSystem().GetLobSystemInstances()[0].Value;
                    IMethodInstance    method            = entity.GetMethodInstance("ReadList", MethodInstanceType.Finder); // Finder method name
                    IView view = entity.GetFinderView(method.Name);

                    IFilterCollection         filterCollection         = entity.GetDefaultFinderFilters();
                    IEntityInstanceEnumerator entityInstanceEnumerator = entity.FindFiltered(filterCollection, method.Name, lobSystemInstance, OperationMode.Online);
                    Console.WriteLine("Employee Login ID | Job Title");
                    while (entityInstanceEnumerator.MoveNext())
                    {
                        Console.WriteLine(entityInstanceEnumerator.Current["LoginID"].ToString() + " - " + entityInstanceEnumerator.Current["JobTitle"].ToString()); // Column names
                    }
                    Console.ReadLine();
                }
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Checks if specified Diagnostic Event meets filtering criteria.
        /// </summary>
        /// <param name="de"></param>
        /// <param name="loggerName"></param>
        /// <param name="filters"></param>
        /// <returns></returns>
        internal bool MeetsFiltersCriteria(IDiagnosticEvent de, ILoggerName loggerName, IFilterCollection filters)
        {
            //# check this loger's filters
            for (int i = 0; i < filters.Count; i++)
            {
                var filter = filters[i];

                bool shouldLog = filter.Evaluate(de, loggerName);

                if (!shouldLog)
                    return false;
            }

            var parentLogger = Parent as DiagnosticLogger;

            if (parentLogger != null)
                return parentLogger.MeetsFiltersCriteria(de, loggerName, filters);

            return true;
        }
 public ConfigurationRepository()
 {
     this.Filters = new FilterCollection();
 }
Exemplo n.º 23
0
        static int iRoundToSecondsMinimum = 10;  // If a TimeSpan takes more than 10 seconds, round off the milliseconds

        /// <summary>
        /// Command Line entrypoint
        /// </summary>
        /// <param name="args">parsed parameter string</param>
        /// <returns></returns>
        static int Main(string[] args)
        {
            // In case it has been renamed, find out what the current name in use is
            // Filename for Help or Error messages
            Location l = new Location();

            sExeFilename = Path.GetFileNameWithoutExtension(Path.GetFileName(l.locationFullPath));

            if (ParseParameters(args) == false)
            {
                return(-1);
            }

            // If no job id or user is defined, give help message
            if ((jobId == 0) && (userName == null))
            {
                help(sExeFilename);
                return(-1);
            }

            try {
                using (IScheduler scheduler = new Scheduler()) {
                    ISchedulerCollection jobs   = null;
                    IFilterCollection    filter = null;
                    ISortCollection      sort   = null;

                    scheduler.Connect(clusterName);

                    // Filter the jobs requested by the parameters, either a single job or a range, and/or a user
                    filter = scheduler.CreateFilterCollection();
                    if (jobIdRange != 0)
                    {
                        filter.Add(FilterOperator.GreaterThanOrEqual, JobPropertyIds.Id, jobId);
                        filter.Add(FilterOperator.LessThanOrEqual, JobPropertyIds.Id, jobIdRange);
                    }
                    else
                    {
                        filter.Add(FilterOperator.Equal, JobPropertyIds.Id, jobId);
                    }

                    if (userName != null)
                    {
                        filter.Add(FilterOperator.Equal, JobPropertyIds.Owner, userName);
                    }

                    // Sort the jobs relative to when they were created
                    sort = scheduler.CreateSortCollection();
                    sort.Add(SortProperty.SortOrder.Ascending, PropId.Job_CreateTime);

                    jobs = scheduler.GetJobList(filter, sort);

                    // Be sure the job(s) can be found
                    if (jobs.Count == 0)
                    {
                        Console.Error.WriteLine(sExeFilename + NOJOBSFOUND);
                        return(-1);
                    }
                    else
                    {
                        foreach (ISchedulerJob job in jobs)
                        {
                            if (bVerbose)
                            {
                                Console.WriteLine("job {0} project: {1}", job.Id, job.Project);
                            }

                            // Is the job part of the project?
                            if ((projectName != null) && (job.Project != projectName))
                            {
                                continue;
                            }
                            else if ((projectNameIgnore != null) && (job.Project.Equals(projectNameIgnore, StringComparison.InvariantCultureIgnoreCase) == false))
                            {
                                continue;
                            }
                            else    // Exact match overrides StartsWith and Contains, only test them if previous tests are not attempted
                            {
                                if ((projectNameBegins != null) && (job.Project.StartsWith(projectNameBegins, StringComparison.InvariantCultureIgnoreCase) == false))
                                {
                                    continue;
                                }
                                if ((projectNameContains != null) && (job.Project.Contains(projectNameContains) == false))
                                {
                                    continue;
                                }
                            }
                            iFilteredJobs++;

                            Console.WriteLine("Job {0} - {1}", job.Id, job.State);
                            Console.WriteLine(job.Name);
                            collectAllocatedInfo(job);
                        }
                    }

                    // Jobs were found within the range, but none had the appropriate project criteria
                    if (iFilteredJobs <= 0)
                    {
                        Console.Error.WriteLine(sExeFilename + NOJOBSFOUND);
                        return(-1);
                    }
                    // Round up/down to seconds if greater than minimum
                    if (tsAllJobUsage.TotalSeconds >= iRoundToSecondsMinimum)
                    {
                        if (tsAllJobUsage.Milliseconds >= 500)
                        {
                            tsAllJobUsage = tsAllJobUsage.Add(TimeSpan.FromMilliseconds(1000 - tsAllJobUsage.Milliseconds));
                        }
                        else
                        {
                            tsAllJobUsage = tsAllJobUsage.Subtract(TimeSpan.FromMilliseconds(tsAllJobUsage.Milliseconds));
                        }
                    }

                    // If a range of jobs was given, or other criteria created selected multiple jobs, show summary
                    if ((jobIdRange > 0) || (iFilteredJobs > 1))
                    {
                        Console.WriteLine("Number of jobs:  {0}", iFilteredJobs);
                        Console.WriteLine("Number of {0}: {1}", bNodesOnly ? "nodes" : "cores", iAllJobThreads);
                        Console.WriteLine("{0} usage across all jobs: {1}", bNodesOnly ? "Node" : "Core", tsAllJobUsage);
                    }
                }
            } catch (Exception e) {
                Console.Error.WriteLine("Exception!");
                Console.Error.WriteLine(e.Message);
            }

            return(iFilteredJobs);
        }
Exemplo n.º 24
0
 void ISetFilters.SetFilters(IFilterCollection filterCollectionNew)
 {
     FilterCollection = filterCollectionNew;
 }