- Timestamp:
- 01/14/09 21:27:54 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Hive.Server.ADODataAccess
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/CachedDataAdapter.cs
r1128 r1131 36 36 where RowT : System.Data.DataRow 37 37 where ObjT : IHiveObject, new() { 38 protected CacheT cache =38 protected static CacheT cache = 39 39 new CacheT(); 40 40 41 protected IDictionary<long, DataTable> dataTable = 42 new Dictionary<long, DataTable>(); 41 private static bool cacheFilled = false; 42 43 protected DataTable dataTable = 44 new DataTable(); 43 45 44 46 protected ICollection<ICachedDataAdapter> parentAdapters = 45 47 new List<ICachedDataAdapter>(); 46 48 49 [MethodImpl(MethodImplOptions.Synchronized)] 47 50 protected CachedDataAdapter() { 48 FillCache(); 51 if (!cacheFilled) { 52 FillCache(); 53 cacheFilled = true; 54 } 49 55 50 56 ServiceLocator.GetTransactionManager().OnUpdate += … … 52 58 } 53 59 54 [MethodImpl(MethodImplOptions.Synchronized)]55 60 protected virtual RowT FindSingleRow(Selector dbSelector, 56 61 Selector cacheSelector) { … … 67 72 } 68 73 69 [MethodImpl(MethodImplOptions.Synchronized)]70 74 protected virtual IEnumerable<RowT> FindMultipleRows(Selector dbSelector, 71 75 Selector cacheSelector) { … … 91 95 if (row != null) { 92 96 ObjT obj = new ObjT(); 93 Convert(row, obj);94 97 obj = Convert(row, obj); 98 95 99 return obj; 96 100 } else { … … 99 103 } 100 104 101 [MethodImpl(MethodImplOptions.Synchronized)]102 105 protected virtual ICollection<ObjT> FindMultiple(Selector dbSelector, 103 106 Selector cacheSelector) { … … 128 131 protected abstract bool PutInCache(ObjT obj); 129 132 130 [MethodImpl(MethodImplOptions.Synchronized)]131 133 protected abstract RowT FindCachedById(long id); 132 134 … … 152 154 } 153 155 154 [MethodImpl(MethodImplOptions.Synchronized)]155 156 protected override RowT GetRowById(long id) { 156 157 RowT row = … … 184 185 obj.Id = (long)row[row.Table.PrimaryKey[0]]; 185 186 186 Convert (obj, row);187 ConvertObj(obj, row); 187 188 188 189 if (!IsCached(row)) … … 192 193 !PutInCache(obj)) { 193 194 //remove from cache 194 dataTable [obj.Id].ImportRow(row);195 dataTable.Remove(obj.Id);195 dataTable.ImportRow(row); 196 RemoveRowFromCache(row); 196 197 197 198 UpdateRow(row); 198 RemoveRowFromCache(row);199 199 } else if (!IsCached(row) && 200 200 PutInCache(obj)) { 201 201 //add to cache 202 202 cache.ImportRow(row); 203 204 dataTable[obj.Id] = row.Table;205 203 row.Table.Rows.Remove(row); 206 } 204 } 207 205 } 208 206 } -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ClientAdapter.cs
r1122 r1131 92 92 93 93 #region Overrides 94 protected override ClientInfo Convert (dsHiveServer.ClientRow row,94 protected override ClientInfo ConvertRow(dsHiveServer.ClientRow row, 95 95 ClientInfo client) { 96 96 if(row != null && client != null) { … … 138 138 } 139 139 140 protected override dsHiveServer.ClientRow Convert (ClientInfo client,140 protected override dsHiveServer.ClientRow ConvertObj(ClientInfo client, 141 141 dsHiveServer.ClientRow row) { 142 142 if (client != null && row != null) { … … 162 162 163 163 protected override void UpdateRow(dsHiveServer.ClientRow row) { 164 adapter.Update(row);164 Adapter.Update(row); 165 165 } 166 166 … … 176 176 protected override dsHiveServer.ClientRow 177 177 InsertNewRowInCache(ClientInfo client) { 178 dsHiveServer.ClientRow row = cache.NewClientRow();178 dsHiveServer.ClientRow row = data.NewClientRow(); 179 179 row.ResourceId = client.Id; 180 180 cache.AddClientRow(row); … … 184 184 185 185 protected override void FillCache() { 186 cache = adapter.GetDataByActive();186 Adapter.FillByActive(cache); 187 187 } 188 188 189 189 public override void SyncWithDb() { 190 adapter.Update(cache);190 Adapter.Update(cache); 191 191 } 192 192 … … 197 197 protected override IEnumerable<dsHiveServer.ClientRow> 198 198 FindById(long id) { 199 return adapter.GetDataByResourceId(id);199 return Adapter.GetDataByResourceId(id); 200 200 } 201 201 … … 208 208 FindAll() { 209 209 return FindMultipleRows( 210 new Selector( adapter.GetData),210 new Selector(Adapter.GetData), 211 211 new Selector(cache.AsEnumerable<dsHiveServer.ClientRow>)); 212 212 } … … 229 229 return base.FindSingle( 230 230 delegate() { 231 return adapter.GetDataById(clientId);231 return Adapter.GetDataById(clientId); 232 232 }, 233 233 delegate() { -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ClientGroupAdapter.cs
r995 r1131 67 67 68 68 #region Overrides 69 protected override ClientGroup Convert (dsHiveServer.ClientGroupRow row,69 protected override ClientGroup ConvertRow(dsHiveServer.ClientGroupRow row, 70 70 ClientGroup clientGroup) { 71 71 if (row != null && clientGroup != null) { … … 129 129 } 130 130 131 protected override dsHiveServer.ClientGroupRow Convert (ClientGroup clientGroup,131 protected override dsHiveServer.ClientGroupRow ConvertObj(ClientGroup clientGroup, 132 132 dsHiveServer.ClientGroupRow row) { 133 133 if (clientGroup != null && row != null) { … … 211 211 212 212 data.AddClientGroupRow(row); 213 adapter.Update(row);213 Adapter.Update(row); 214 214 215 215 return row; … … 218 218 protected override void 219 219 UpdateRow(dsHiveServer.ClientGroupRow row) { 220 adapter.Update(row);220 Adapter.Update(row); 221 221 } 222 222 223 223 protected override IEnumerable<dsHiveServer.ClientGroupRow> 224 224 FindById(long id) { 225 return adapter.GetDataById(id);225 return Adapter.GetDataById(id); 226 226 } 227 227 228 228 protected override IEnumerable<dsHiveServer.ClientGroupRow> 229 229 FindAll() { 230 return adapter.GetData();230 return Adapter.GetData(); 231 231 } 232 232 #endregion -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/DBSettings.cs
r1120 r1131 44 44 public static String GetConnString(String adress, String catalog, String un, String pw) { 45 45 return "Data Source=" + adress + ";Initial Catalog=" + catalog + ";MultipleActiveResultSets=True;" + 46 " Persist Security Info=True;User ID=" + un + ";Password=" + pw;46 "Asynchronous Processing=True;Persist Security Info=True;User ID=" + un + ";Password=" + pw; 47 47 } 48 48 -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/DataAdapterBase.cs
r1128 r1131 21 21 22 22 using System; 23 using System.Data; 23 24 using System.Collections.Generic; 24 25 using System.Linq; … … 32 33 where RowT : System.Data.DataRow 33 34 where ObjT : IHiveObject, new() { 34 protected AdapterT adapter = 35 new AdapterT(); 35 protected AdapterT Adapter { 36 get { 37 return new AdapterT(); 38 } 39 } 36 40 37 41 #region Abstract methods 38 protected abstract RowT Convert (ObjT obj, RowT row);42 protected abstract RowT ConvertObj(ObjT obj, RowT row); 39 43 40 protected abstract ObjT Convert (RowT row, ObjT obj);44 protected abstract ObjT ConvertRow(RowT row, ObjT obj); 41 45 42 46 [MethodImpl(MethodImplOptions.Synchronized)] … … 46 50 protected abstract void UpdateRow(RowT row); 47 51 48 [MethodImpl(MethodImplOptions.Synchronized)]49 52 protected abstract IEnumerable<RowT> FindById(long id); 50 53 51 [MethodImpl(MethodImplOptions.Synchronized)]52 54 protected abstract IEnumerable<RowT> FindAll(); 53 55 #endregion … … 55 57 protected delegate IEnumerable<RowT> Selector(); 56 58 57 [MethodImpl(MethodImplOptions.Synchronized)] 59 protected ObjT Convert(RowT row, ObjT obj) { 60 try { 61 obj = ConvertRow(row, obj); 62 return obj; 63 } 64 catch (DeletedRowInaccessibleException) { 65 return default(ObjT); 66 } 67 catch (RowNotInTableException) { 68 return default(ObjT); 69 } 70 } 71 58 72 protected virtual RowT FindSingleRow(Selector selector) { 59 73 RowT row = default(RowT); … … 73 87 if (row != null) { 74 88 ObjT obj = new ObjT(); 75 Convert(row, obj);89 obj = Convert(row, obj); 76 90 77 91 return obj; … … 81 95 } 82 96 83 [MethodImpl(MethodImplOptions.Synchronized)]84 97 protected virtual ICollection<ObjT> FindMultiple(Selector selector) { 85 98 IEnumerable<RowT> found = … … 91 104 foreach (RowT row in found) { 92 105 ObjT obj = new ObjT(); 93 Convert(row, obj); 94 result.Add(obj); 106 obj = Convert(row, obj); 107 if(obj != null) 108 result.Add(obj); 95 109 } 96 110 … … 115 129 } 116 130 117 Convert (obj, row);131 ConvertObj(obj, row); 118 132 119 133 UpdateRow(row); -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/JobAdapter.cs
r1120 r1131 77 77 78 78 #region Overrides 79 protected override Job Convert (dsHiveServer.JobRow row,79 protected override Job ConvertRow(dsHiveServer.JobRow row, 80 80 Job job) { 81 81 if (row != null && job != null) { … … 112 112 } 113 113 114 protected override dsHiveServer.JobRow Convert (Job job,114 protected override dsHiveServer.JobRow ConvertObj(Job job, 115 115 dsHiveServer.JobRow row) { 116 116 if (job != null && row != null) { … … 147 147 148 148 protected override void UpdateRow(dsHiveServer.JobRow row) { 149 adapter.Update(row);149 Adapter.Update(row); 150 150 } 151 151 … … 160 160 protected override dsHiveServer.JobRow 161 161 InsertNewRowInCache(Job job) { 162 dsHiveServer.JobRow row = cache.NewJobRow();162 dsHiveServer.JobRow row = data.NewJobRow(); 163 163 cache.AddJobRow(row); 164 164 … … 167 167 168 168 protected override void FillCache() { 169 adapter.FillByActive(cache);169 Adapter.FillByActive(cache); 170 170 } 171 171 172 172 public override void SyncWithDb() { 173 this. adapter.Update(this.cache);173 this.Adapter.Update(cache); 174 174 } 175 175 … … 182 182 protected override IEnumerable<dsHiveServer.JobRow> 183 183 FindById(long id) { 184 return adapter.GetDataById(id);184 return Adapter.GetDataById(id); 185 185 } 186 186 … … 193 193 FindAll() { 194 194 return FindMultipleRows( 195 new Selector( adapter.GetData),195 new Selector(Adapter.GetData), 196 196 new Selector(cache.AsEnumerable<dsHiveServer.JobRow>)); 197 197 } … … 205 205 base.FindMultiple( 206 206 delegate() { 207 return adapter.GetDataBySubjobs(job.Id);207 return Adapter.GetDataBySubjobs(job.Id); 208 208 }, 209 209 delegate() { … … 223 223 base.FindMultiple( 224 224 delegate() { 225 return adapter.GetDataByState(state.ToString());225 return Adapter.GetDataByState(state.ToString()); 226 226 }, 227 227 delegate() { … … 239 239 base.FindMultiple( 240 240 delegate() { 241 return adapter.GetDataByClient(client.Id);241 return Adapter.GetDataByClient(client.Id); 242 242 }, 243 243 delegate() { … … 258 258 base.FindMultiple( 259 259 delegate() { 260 return adapter.GetDataByUser(user.Id);260 return Adapter.GetDataByUser(user.Id); 261 261 }, 262 262 delegate() { -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/JobResultsAdapter.cs
r1103 r1131 40 40 41 41 #region Overrides 42 protected override dsHiveServer.JobResultRow Convert (JobResult result,42 protected override dsHiveServer.JobResultRow ConvertObj(JobResult result, 43 43 dsHiveServer.JobResultRow row) { 44 44 if (row != null && result != null) { … … 75 75 } 76 76 77 protected override JobResult Convert (dsHiveServer.JobResultRow row,77 protected override JobResult ConvertRow(dsHiveServer.JobResultRow row, 78 78 JobResult result) { 79 79 if (row != null && result != null) { … … 106 106 107 107 protected override void UpdateRow(dsHiveServer.JobResultRow row) { 108 adapter.Update(row);108 Adapter.Update(row); 109 109 } 110 110 … … 117 117 118 118 protected override IEnumerable<dsHiveServer.JobResultRow> FindById(long id) { 119 return adapter.GetDataById(id);119 return Adapter.GetDataById(id); 120 120 } 121 121 122 122 protected override IEnumerable<dsHiveServer.JobResultRow> FindAll() { 123 return adapter.GetData();123 return Adapter.GetData(); 124 124 } 125 125 #endregion … … 140 140 base.FindMultiple( 141 141 delegate() { 142 return adapter.GetDataByJob(job.Id);142 return Adapter.GetDataByJob(job.Id); 143 143 }); 144 144 } -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/PermissionOwnerAdapter.cs
r995 r1131 42 42 43 43 #region Overrides 44 protected override PermissionOwner Convert (dsHiveServer.PermissionOwnerRow row,44 protected override PermissionOwner ConvertRow(dsHiveServer.PermissionOwnerRow row, 45 45 PermissionOwner permOwner) { 46 46 if (row != null && permOwner != null) { … … 57 57 } 58 58 59 protected override dsHiveServer.PermissionOwnerRow Convert (PermissionOwner permOwner,59 protected override dsHiveServer.PermissionOwnerRow ConvertObj(PermissionOwner permOwner, 60 60 dsHiveServer.PermissionOwnerRow row) { 61 61 if (row != null && permOwner != null) { … … 79 79 protected override void 80 80 UpdateRow(dsHiveServer.PermissionOwnerRow row) { 81 adapter.Update(row);81 Adapter.Update(row); 82 82 } 83 83 84 84 protected override IEnumerable<dsHiveServer.PermissionOwnerRow> 85 85 FindById(long id) { 86 return adapter.GetDataById(id);86 return Adapter.GetDataById(id); 87 87 } 88 88 89 89 protected override IEnumerable<dsHiveServer.PermissionOwnerRow> 90 90 FindAll() { 91 return adapter.GetData();91 return Adapter.GetData(); 92 92 } 93 93 #endregion … … 114 114 return base.FindSingle( 115 115 delegate() { 116 return adapter.GetDataByName(name);116 return Adapter.GetDataByName(name); 117 117 }); 118 118 } -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ResourceAdapter.cs
r1096 r1131 53 53 54 54 #region Overrides 55 protected override Resource Convert (dsHiveServer.ResourceRow row,55 protected override Resource ConvertRow(dsHiveServer.ResourceRow row, 56 56 Resource resource) { 57 57 if (row != null && resource != null) { … … 67 67 } 68 68 69 protected override dsHiveServer.ResourceRow Convert (Resource resource,69 protected override dsHiveServer.ResourceRow ConvertObj(Resource resource, 70 70 dsHiveServer.ResourceRow row) { 71 71 if (resource != null && row != null) { … … 78 78 79 79 protected override void UpdateRow(dsHiveServer.ResourceRow row) { 80 adapter.Update(row);80 Adapter.Update(row); 81 81 } 82 82 … … 98 98 99 99 protected override void FillCache() { 100 cache = adapter.GetDataByActive();100 Adapter.FillByActive(cache); 101 101 } 102 102 103 103 public override void SyncWithDb() { 104 adapter.Update(cache);104 Adapter.Update(cache); 105 105 } 106 106 … … 112 112 protected override IEnumerable<dsHiveServer.ResourceRow> 113 113 FindById(long id) { 114 return adapter.GetDataById(id);114 return Adapter.GetDataById(id); 115 115 } 116 116 … … 123 123 FindAll() { 124 124 return FindMultipleRows( 125 new Selector( adapter.GetData),125 new Selector(Adapter.GetData), 126 126 new Selector(cache.AsEnumerable<dsHiveServer.ResourceRow>)); 127 127 } … … 149 149 base.FindSingleRow( 150 150 delegate() { 151 return adapter.GetDataByName(name);151 return Adapter.GetDataByName(name); 152 152 }, 153 153 delegate() { … … 161 161 if (row != null) { 162 162 Resource res = new Resource(); 163 Convert(row, res);163 res = Convert(row, res); 164 164 165 165 return res; -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/UserAdapter.cs
r1009 r1131 75 75 76 76 #region Overrides 77 protected override User Convert (dsHiveServer.HiveUserRow row,77 protected override User ConvertRow(dsHiveServer.HiveUserRow row, 78 78 User user) { 79 79 if (row != null && user != null) { … … 93 93 } 94 94 95 protected override dsHiveServer.HiveUserRow Convert (User user,95 protected override dsHiveServer.HiveUserRow ConvertObj(User user, 96 96 dsHiveServer.HiveUserRow row) { 97 97 if (user != null && row != null) { … … 120 120 protected override void 121 121 UpdateRow(dsHiveServer.HiveUserRow row) { 122 adapter.Update(row);122 Adapter.Update(row); 123 123 } 124 124 125 125 protected override IEnumerable<dsHiveServer.HiveUserRow> 126 126 FindById(long id) { 127 return adapter.GetDataById(id);127 return Adapter.GetDataById(id); 128 128 } 129 129 130 130 protected override IEnumerable<dsHiveServer.HiveUserRow> 131 131 FindAll() { 132 return adapter.GetData();132 return Adapter.GetData(); 133 133 } 134 134 #endregion … … 149 149 return base.FindSingle( 150 150 delegate() { 151 return adapter.GetDataByName(name);151 return Adapter.GetDataByName(name); 152 152 }); 153 153 } -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/UserGroupAdapter.cs
r995 r1131 69 69 70 70 #region Overrides 71 protected override UserGroup Convert (dsHiveServer.UserGroupRow row,71 protected override UserGroup ConvertRow(dsHiveServer.UserGroupRow row, 72 72 UserGroup userGroup) { 73 73 if (row != null && userGroup != null) { … … 130 130 } 131 131 132 protected override dsHiveServer.UserGroupRow Convert (UserGroup userGroup,132 protected override dsHiveServer.UserGroupRow ConvertObj(UserGroup userGroup, 133 133 dsHiveServer.UserGroupRow row) { 134 134 if (userGroup != null && row != null) { … … 212 212 213 213 data.AddUserGroupRow(row); 214 adapter.Update(row);214 Adapter.Update(row); 215 215 216 216 return row; … … 219 219 protected override void 220 220 UpdateRow(dsHiveServer.UserGroupRow row) { 221 adapter.Update(row);221 Adapter.Update(row); 222 222 } 223 223 224 224 protected override IEnumerable<dsHiveServer.UserGroupRow> 225 225 FindById(long id) { 226 return adapter.GetDataById(id);226 return Adapter.GetDataById(id); 227 227 } 228 228 229 229 protected override IEnumerable<dsHiveServer.UserGroupRow> 230 230 FindAll() { 231 return adapter.GetData();231 return Adapter.GetData(); 232 232 } 233 233 #endregion … … 247 247 return base.FindSingle( 248 248 delegate() { 249 return adapter.GetDataByName(name);249 return Adapter.GetDataByName(name); 250 250 }); 251 251 }
Note: See TracChangeset
for help on using the changeset viewer.