Changeset 5995


Ignore:
Timestamp:
Aug 21, 2020, 11:49:41 AM (3 years ago)
Author:
Nicklas Nordborg
Message:

References #1259: Add support for Slurm

Added support for filtering when retrieving configured clusters.

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  
    175175    private final int timeAdjustment;
    176176    private final boolean error;
     177    private final boolean connected;
    177178   
    178179    Info(OpenGridSession session)
     
    183184      timeAdjustment = session.getTimeAdjustment();
    184185      error = hostInfo.getExitStatus() != 0 || ogsInfo.getExitStatus() != 0;
     186      connected = true;
    185187    }
    186188   
     
    200202      timeAdjustment = 0;
    201203      error = true;
     204      connected = false;
    202205    }
    203206   
     
    208211    {
    209212      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;
    210222    }
    211223   
     
    243255      json.put("hostInfo", hostInfo.asJSONObject(options));
    244256      json.put("openGridInfo", ogsInfo.asJSONObject(options));
     257      json.put("connected", connected);
    245258      json.put("error", error);
    246259      return json;
  • extensions/net.sf.basedb.opengrid/trunk/src/net/sf/basedb/opengrid/service/OpenGridService.java

    r5505 r5995  
    4545import net.sf.basedb.util.extensions.Registry;
    4646import net.sf.basedb.util.extensions.manager.Settings;
     47import net.sf.basedb.util.filter.Filter;
     48import net.sf.basedb.util.filter.StaticFilter;
    4749
    4850/**
     
    158160 
    159161  /**
     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  /**
    160170    Get all clusters that the logged in user is allowed to use.
    161171    This method uses a query for job agents with the given include
     
    166176    @param include A set of include options for the job agent query
    167177      (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)
    170182  {
    171183    ItemQuery<JobAgent> query = JobAgent.getQuery();
    172184    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);
    174194  }
    175195 
     
    182202      If null or empty, only clusters that are open to all are
    183203      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)
    186208  {
    187209    // Collect the external id of the given job agents
     
    199221   
    200222    List<OpenGridCluster> result = new ArrayList<>();
     223    if (filter == null) filter = new StaticFilter<OpenGridCluster>(true);
    201224    for (OpenGridCluster cluster : clusters.values())
    202225    {
    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        }
    207233      }
    208234    }
Note: See TracChangeset for help on using the changeset viewer.