Changeset 5995
- Timestamp:
- Aug 21, 2020, 11:49:41 AM (3 years ago)
- Location:
- extensions/net.sf.basedb.opengrid/trunk/src/net/sf/basedb/opengrid
- Files:
-
- 4 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.opengrid/trunk/src/net/sf/basedb/opengrid/OpenGridCluster.java
r5980 r5995 175 175 private final int timeAdjustment; 176 176 private final boolean error; 177 private final boolean connected; 177 178 178 179 Info(OpenGridSession session) … … 183 184 timeAdjustment = session.getTimeAdjustment(); 184 185 error = hostInfo.getExitStatus() != 0 || ogsInfo.getExitStatus() != 0; 186 connected = true; 185 187 } 186 188 … … 200 202 timeAdjustment = 0; 201 203 error = true; 204 connected = false; 202 205 } 203 206 … … 208 211 { 209 212 return created; 213 } 214 215 /** 216 TRUE if was possible to connect to the cluster, FALSE otherwise. 217 @since 1.4 218 */ 219 public boolean isConnected() 220 { 221 return connected; 210 222 } 211 223 … … 243 255 json.put("hostInfo", hostInfo.asJSONObject(options)); 244 256 json.put("openGridInfo", ogsInfo.asJSONObject(options)); 257 json.put("connected", connected); 245 258 json.put("error", error); 246 259 return json; -
extensions/net.sf.basedb.opengrid/trunk/src/net/sf/basedb/opengrid/service/OpenGridService.java
r5505 r5995 45 45 import net.sf.basedb.util.extensions.Registry; 46 46 import net.sf.basedb.util.extensions.manager.Settings; 47 import net.sf.basedb.util.filter.Filter; 48 import net.sf.basedb.util.filter.StaticFilter; 47 49 48 50 /** … … 158 160 159 161 /** 162 @see #getClusters(DbControl, Collection, Filter) 163 */ 164 public Collection<OpenGridCluster> getClusters(DbControl dc, Collection<Include> include) 165 { 166 return getClusters(dc, include, null); 167 } 168 169 /** 160 170 Get all clusters that the logged in user is allowed to use. 161 171 This method uses a query for job agents with the given include … … 166 176 @param include A set of include options for the job agent query 167 177 (if null the default query options are used) 168 */ 169 public Collection<OpenGridCluster> getClusters(DbControl dc, Collection<Include> include) 178 @param filter Optional filter, if not specified all clusters are returned 179 @since 1.4 180 */ 181 public Collection<OpenGridCluster> getClusters(DbControl dc, Collection<Include> include, Filter<OpenGridCluster> filter) 170 182 { 171 183 ItemQuery<JobAgent> query = JobAgent.getQuery(); 172 184 if (include != null) query.setIncludes(include); 173 return getClusters(query.list(dc)); 185 return getClusters(query.list(dc), filter); 186 } 187 188 /** 189 @see #getClusters(Collection, Filter) 190 */ 191 public Collection<OpenGridCluster> getClusters(Collection<JobAgent> jobAgents) 192 { 193 return getClusters(jobAgents, null); 174 194 } 175 195 … … 182 202 If null or empty, only clusters that are open to all are 183 203 returned 184 */ 185 public Collection<OpenGridCluster> getClusters(Collection<JobAgent> jobAgents) 204 @param filter Optional filter, if not specified all clusters are returned 205 @since 1.4 206 */ 207 public Collection<OpenGridCluster> getClusters(Collection<JobAgent> jobAgents, Filter<OpenGridCluster> filter) 186 208 { 187 209 // Collect the external id of the given job agents … … 199 221 200 222 List<OpenGridCluster> result = new ArrayList<>(); 223 if (filter == null) filter = new StaticFilter<OpenGridCluster>(true); 201 224 for (OpenGridCluster cluster : clusters.values()) 202 225 { 203 String jobAgentId = cluster.getConfig().getJobAgentExternalId(); 204 if (jobAgentId == null || usableJobAgents.contains(jobAgentId)) 205 { 206 result.add(cluster); 226 if (filter.evaluate(cluster)) 227 { 228 String jobAgentId = cluster.getConfig().getJobAgentExternalId(); 229 if (jobAgentId == null || usableJobAgents.contains(jobAgentId)) 230 { 231 result.add(cluster); 232 } 207 233 } 208 234 }
Note: See TracChangeset
for help on using the changeset viewer.