Пример #1
0
 public Guid AddTask(DT.Task task, DT.TaskData taskData, IEnumerable<Guid> resourceIds) {
   RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
   var pm = PersistenceManager;
   using (new PerformanceLogger("AddTask")) {
     var taskDao = pm.TaskDao;
     var stateLogDao = pm.StateLogDao;
     var newTask = task.ToEntity();
     newTask.JobData = taskData.ToEntity();
     newTask.JobData.LastUpdate = DateTime.Now;
     newTask.AssignedResources.AddRange(resourceIds.Select(
       x => new DA.AssignedResource {
         ResourceId = x
       }));
     newTask.State = DA.TaskState.Waiting;
     return pm.UseTransaction(() => {
       taskDao.Save(newTask);
       pm.SubmitChanges();
       stateLogDao.Save(new DA.StateLog {
         State = DA.TaskState.Waiting,
         DateTime = DateTime.Now,
         TaskId = newTask.TaskId,
         UserId = UserManager.CurrentUserId,
         SlaveId = null,
         Exception = null
       });
       pm.SubmitChanges();
       return newTask.TaskId;
     }, false, true);
   }
 }
Пример #2
0
 public void AuthorizeForTask(Guid taskId, DT.Permission requiredPermission) {
   if (ServiceLocator.Instance.RoleVerifier.IsInRole(HiveRoles.Slave)) return; // slave-users can access all tasks
   var pm = PersistenceManager;
   var taskDao = pm.TaskDao;
   pm.UseTransaction(() => {
     var task = taskDao.GetById(taskId);
     if (task == null) throw new SecurityException(NOT_AUTHORIZED);
     AuthorizeJob(pm, task.JobId, requiredPermission);
   });
 }
Пример #3
0
 public static void ToEntityTaskOnly(DT.Task source, DB.Task target) {
   if ((source != null) && (target != null)) {
     target.TaskId = source.Id;
     target.CoresNeeded = source.CoresNeeded;
     target.ExecutionTimeMs = source.ExecutionTime.TotalMilliseconds;
     target.MemoryNeeded = source.MemoryNeeded;
     target.ParentTaskId = source.ParentTaskId;
     target.Priority = source.Priority;
     target.LastHeartbeat = source.LastHeartbeat;
     target.State = Convert.ToEntity(source.State);
     target.IsParentTask = source.IsParentTask;
     target.FinishWhenChildJobsFinished = source.FinishWhenChildJobsFinished;
     target.Command = Convert.ToEntity(source.Command);
     // RequiredPlugins are added by Dao
     target.JobId = source.JobId;
     target.IsPrivileged = source.IsPrivileged;
   }
 }
Пример #4
0
 public static void ToEntity(DT.StateLog source, DB.StateLog target) {
   if ((source != null) && (target != null)) {
     target.StateLogId = source.Id; target.DateTime = source.DateTime; target.Exception = source.Exception; target.TaskId = source.TaskId; target.SlaveId = source.SlaveId; target.State = Convert.ToEntity(source.State); target.UserId = source.UserId;
   }
 }
Пример #5
0
 public static void ToEntity(DT.SlaveStatistics source, DB.SlaveStatistics target) {
   if ((source != null) && (target != null)) {
     target.StatisticsId = source.Id;
     target.SlaveId = source.SlaveId;
     target.Cores = source.Cores;
     target.CpuUtilization = source.CpuUtilization;
     target.FreeCores = source.FreeCores;
     target.FreeMemory = source.FreeMemory;
     target.Memory = source.Memory;
   }
 }
Пример #6
0
 public static DB.SlaveState ToEntity(DT.SlaveState source) {
   if (source == DT.SlaveState.Calculating) {
     return DB.SlaveState.Calculating;
   } else if (source == DT.SlaveState.Idle) {
     return DB.SlaveState.Idle;
   } else if (source == DT.SlaveState.Offline) {
     return DB.SlaveState.Offline;
   } else
     return DB.SlaveState.Offline;
 }
Пример #7
0
 public static void ToEntity(DT.UserPriority source, DB.UserPriority target) {
   if ((source != null) && (target != null)) {
     target.UserId = source.Id;
     target.DateEnqueued = source.DateEnqueued;
   }
 }
Пример #8
0
 public static DB.Permission ToEntity(DT.Permission source) {
   if (source == DT.Permission.Full) {
     return DB.Permission.Full;
   } else if (source == DT.Permission.NotAllowed) {
     return DB.Permission.NotAllowed;
   } else if (source == DT.Permission.Read) {
     return DB.Permission.Read;
   } else
     return DB.Permission.NotAllowed;
 }
Пример #9
0
 public static DB.CpuArchitecture ToEntity(DT.CpuArchitecture source) {
   if (source == DT.CpuArchitecture.x64) {
     return DB.CpuArchitecture.x64;
   } else if (source == DT.CpuArchitecture.x86) {
     return DB.CpuArchitecture.x86;
   } else
     return DB.CpuArchitecture.x86;
 }
Пример #10
0
 public static DB.PluginData ToEntity(DT.PluginData source) {
   if (source == null) return null;
   var entity = new DB.PluginData(); ToEntity(source, entity);
   return entity;
 }
Пример #11
0
 public static void ToEntity(DT.UserStatistics source, DB.UserStatistics target) {
   if ((source != null) && (target != null)) {
     target.StatisticsId = source.Id;
     target.UserId = source.UserId;
     target.UsedCores = source.UsedCores;
     target.ExecutionTimeMs = source.ExecutionTime.TotalMilliseconds;
     target.ExecutionTimeMsFinishedJobs = source.ExecutionTimeFinishedJobs.TotalMilliseconds;
     target.StartToEndTimeMs = source.StartToEndTime.TotalMilliseconds;
   }
 }
Пример #12
0
 public static void ToEntity(DT.JobPermission source, DB.JobPermission target) {
   if ((source != null) && (target != null)) {
     target.JobId = source.JobId; target.GrantedUserId = source.GrantedUserId; target.GrantedByUserId = source.GrantedByUserId; target.Permission = Convert.ToEntity(source.Permission);
   }
 }
Пример #13
0
 public static void ToEntity(DT.Plugin source, DB.Plugin target) {
   if ((source != null) && (target != null)) {
     target.PluginId = source.Id; target.Name = source.Name; target.Version = source.Version.ToString(); target.UserId = source.UserId; target.DateCreated = source.DateCreated; target.Hash = source.Hash;
   }
 }
Пример #14
0
 public static void ToEntity(DT.Job source, DB.Job target) {
   if ((source != null) && (target != null)) {
     target.JobId = source.Id; target.Description = source.Description; target.Name = source.Name; target.OwnerUserId = source.OwnerUserId; target.DateCreated = source.DateCreated; target.ResourceIds = source.ResourceNames;
   }
 }
Пример #15
0
 public static DB.Job ToEntity(DT.Job source) {
   if (source == null) return null;
   var entity = new DB.Job(); ToEntity(source, entity);
   return entity;
 }
Пример #16
0
 public static void ToEntity(DT.Downtime source, DB.Downtime target) {
   if ((source != null) && (target != null)) {
     target.DowntimeId = source.Id; target.AllDayEvent = source.AllDayEvent; target.EndDate = source.EndDate; target.Recurring = source.Recurring; target.RecurringId = source.RecurringId; target.ResourceId = source.ResourceId; target.StartDate = source.StartDate; target.DowntimeType = source.DowntimeType;
   }
 }
Пример #17
0
    public static void ToEntity(DT.Statistics source, DB.Statistics target) {
      if ((source != null) && (target != null)) {
        target.StatisticsId = source.Id;
        target.Timestamp = source.TimeStamp;

      }
    }
Пример #18
0
 public static void ToEntity(DT.PluginData source, DB.PluginData target) {
   if ((source != null) && (target != null)) {
     target.PluginDataId = source.Id;
     target.PluginId = source.PluginId;
     target.Data = source.Data;
     target.FileName = source.FileName;
   }
 }
Пример #19
0
 public static DB.UserStatistics ToEntity(DT.UserStatistics source) {
   if (source == null) return null;
   var entity = new DB.UserStatistics(); ToEntity(source, entity);
   return entity;
 }
Пример #20
0
 public static void ToEntity(DT.SlaveGroup source, DB.SlaveGroup target) {
   if ((source != null) && (target != null)) {
     target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId; target.HbInterval = source.HbInterval; target.OwnerUserId = source.OwnerUserId;
   }
 }
Пример #21
0
 public static DB.TaskState ToEntity(DT.TaskState source) {
   if (source == DT.TaskState.Aborted) {
     return DB.TaskState.Aborted;
   } else if (source == DT.TaskState.Calculating) {
     return DB.TaskState.Calculating;
   } else if (source == DT.TaskState.Failed) {
     return DB.TaskState.Failed;
   } else if (source == DT.TaskState.Finished) {
     return DB.TaskState.Finished;
   } else if (source == DT.TaskState.Offline) {
     return DB.TaskState.Offline;
   } else if (source == DT.TaskState.Paused) {
     return DB.TaskState.Paused;
   } else if (source == DT.TaskState.Transferring) {
     return DB.TaskState.Transferring;
   } else if (source == DT.TaskState.Waiting) {
     return DB.TaskState.Waiting;
   } else
     return DB.TaskState.Failed;
 }
Пример #22
0
 public static DB.Slave ToEntity(DT.Slave source) {
   if (source == null) return null;
   var entity = new DB.Slave(); ToEntity(source, entity);
   return entity;
 }
Пример #23
0
 public static DB.Command? ToEntity(DT.Command? source) {
   if (source.HasValue) {
     if (source == DT.Command.Abort) {
       return DB.Command.Abort;
     } else if (source == DT.Command.Pause) {
       return DB.Command.Pause;
     } else if (source == DT.Command.Stop) {
       return DB.Command.Stop;
     } else
       return DB.Command.Pause;
   } else
     return null;
 }
Пример #24
0
 public static void ToEntity(DT.Slave source, DB.Slave target) {
   if ((source != null) && (target != null)) {
     target.ResourceId = source.Id;
     target.ParentResourceId = source.ParentResourceId;
     target.Cores = source.Cores;
     target.CpuSpeed = source.CpuSpeed;
     target.FreeCores = source.FreeCores;
     target.FreeMemory = source.FreeMemory;
     target.IsAllowedToCalculate = source.IsAllowedToCalculate;
     target.Memory = source.Memory;
     target.Name = source.Name;
     target.SlaveState = Convert.ToEntity(source.SlaveState);
     target.CpuArchitecture = Convert.ToEntity(source.CpuArchitecture);
     target.OperatingSystem = source.OperatingSystem;
     target.LastHeartbeat = source.LastHeartbeat;
     target.CpuUtilization = source.CpuUtilization;
     target.HbInterval = source.HbInterval;
     target.IsDisposable = source.IsDisposable;
     target.OwnerUserId = source.OwnerUserId;
   }
 }
Пример #25
0
 public static DB.Task ToEntity(DT.Task source) {
   if (source == null) return null;
   var entity = new DB.Task(); ToEntity(source, entity);
   return entity;
 }
Пример #26
0
 public static void ToEntity(DT.TaskData source, DB.TaskData target) {
   if ((source != null) && (target != null)) {
     target.TaskId = source.TaskId;
     target.Data = source.Data;
     target.LastUpdate = source.LastUpdate;
   }
 }
Пример #27
0
 public static DB.UserPriority ToEntity(DT.UserPriority source) {
   if (source == null) return null;
   var entity = new DB.UserPriority(); ToEntity(source, entity);
   return entity;
 }
Пример #28
0
 public static void ToEntity(DT.ResourcePermission source, DB.ResourcePermission target) {
   if ((source != null) && (target != null)) {
     target.ResourceId = source.ResourceId; target.GrantedUserId = source.GrantedUserId; target.GrantedByUserId = source.GrantedByUserId;
   }
 }
Пример #29
0
 public static DB.ResourcePermission ToEntity(DT.ResourcePermission source) {
   if (source == null) return null;
   var entity = new DB.ResourcePermission(); ToEntity(source, entity);
   return entity;
 }
Пример #30
0
 public static DB.StateLog ToEntity(DT.StateLog source) {
   if (source == null) return null;
   var entity = new DB.StateLog(); ToEntity(source, entity);
   return entity;
 }