mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jvergara
08.29.2007 aaee394b8c7fdcb653d09d35ea1a28e574632a22
Do not display the replication monitoring information if there are no replicated suffixes.

Fix a number of bugs related to the refresh of the contents of the status panel when the data to be displayed changes (the panel did not get refreshed).
10 files modified
278 ■■■■ changed files
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/BaseDNDescriptor.java 19 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ConfigFromFile.java 48 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ConfigFromLDAP.java 37 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/DatabaseDescriptor.java 17 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ListenerDescriptor.java 17 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ServerStatusDescriptor.java 8 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ServerStatusPooler.java 4 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusCli.java 2 ●●● patch | view | raw | blame | history
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ui/DatabasesTableModel.java 13 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ui/StatusPanelDialog.java 113 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/BaseDNDescriptor.java
@@ -34,7 +34,7 @@
 * used by the classes in the DatabasesTableModel class.
 *
 */
public class BaseDNDescriptor
public class BaseDNDescriptor implements Comparable
{
  /**
   * An enumeration describing the type of base DN for a given Database.
@@ -102,7 +102,6 @@
        getDatabase().getBackendID().equals(
            desc.getDatabase().getBackendID()) &&
        (getDatabase().getEntries() == desc.getDatabase().getEntries());
      }
    }
    else
@@ -118,8 +117,22 @@
  public int hashCode()
  {
    return (getType().toString() + getAgeOfOldestMissingChange() + getDn() +
        getMissingChanges()).hashCode();
        getDatabase().getBackendID() + getMissingChanges()).hashCode();
  }
  /**
   * {@inheritDoc}
   */
  public int compareTo(Object o)
  {
    int returnValue = -1;
    if (o instanceof BaseDNDescriptor)
    {
      BaseDNDescriptor desc = (BaseDNDescriptor)o;
      returnValue = desc.getDn().compareTo(getDn());
    }
    return returnValue;
  }
  /**
   * Returns the number of missing changes in the replication topology for
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ConfigFromFile.java
@@ -100,13 +100,14 @@
    administrativeUsers.clear();
    replicationConfigured = false;
    replicatedSuffixes.clear();
    LDIFReader reader = null;
    try
    {
      Installation installation =
              new Installation(Utils.getInstallPathFromClasspath());
      LDIFImportConfig c = new LDIFImportConfig(
          Utils.getPath(installation.getCurrentConfigurationFile()));
      LDIFReader reader = new LDIFReader(c);
      reader = new LDIFReader(c);
      for (Entry entry = reader.readEntry(false); entry != null;
      entry = reader.readEntry(false))
      {
@@ -131,6 +132,19 @@
      errorMessage = Utils.getThrowableMsg(getI18n(),
          "error-reading-config-file", null, t);
    }
    finally
    {
      if (reader != null)
      {
        try
        {
          reader.close();
        }
        catch (Throwable t)
        {
        }
      }
    }
  }
  /**
@@ -139,7 +153,9 @@
   */
  public HashSet<String> getAdministrativeUsers()
  {
    return administrativeUsers;
    HashSet<String> copy = new HashSet<String>();
    copy.addAll(administrativeUsers);
    return copy;
  }
  /**
@@ -148,7 +164,9 @@
   */
  public HashSet<DatabaseDescriptor> getDatabases()
  {
    return databases;
    HashSet<DatabaseDescriptor> copy = new HashSet<DatabaseDescriptor>();
    copy.addAll(databases);
    return copy;
  }
  /**
@@ -157,7 +175,9 @@
   */
  public HashSet<ListenerDescriptor> getListeners()
  {
    return listeners;
    HashSet<ListenerDescriptor> copy = new HashSet<ListenerDescriptor>();
    copy.addAll(listeners);
    return copy;
  }
  /**
@@ -377,21 +397,18 @@
    if (!isConfigBackend(id))
    {
      Set<String> baseDns = new TreeSet<String>();
      baseDns.addAll(getValues(entry, "ds-cfg-backend-base-dn"));
      Set<BaseDNDescriptor> replicas = new LinkedHashSet<BaseDNDescriptor>();
      Set<String> baseDns = getValues(entry, "ds-cfg-backend-base-dn");
      TreeSet<BaseDNDescriptor> replicas = new TreeSet<BaseDNDescriptor>();
      DatabaseDescriptor db = new DatabaseDescriptor(id, replicas, nEntries);
      for (String baseDn : baseDns)
      {
        replicas.add(getBaseDNDescriptor(entry, baseDn));
      }
      DatabaseDescriptor db = new DatabaseDescriptor(id, replicas, nEntries);
      databases.add(db);
      for (BaseDNDescriptor rep: replicas)
      {
        BaseDNDescriptor rep = getBaseDNDescriptor(entry, baseDn);
        rep.setDatabase(db);
        db.getBaseDns().add(rep);
      }
      databases.add(db);
    }
  }
@@ -453,8 +470,7 @@
        }
        if (replica != null)
        {
          replica.setType(BaseDNDescriptor.Type.REPLICATED);
        }
          replica.setType(BaseDNDescriptor.Type.REPLICATED);        }
      }
    }
  }
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ConfigFromLDAP.java
@@ -29,7 +29,6 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.TreeSet;
@@ -204,25 +203,31 @@
   */
  public HashSet<String> getAdministrativeUsers()
  {
    return administrativeUsers;
    HashSet<String> copy = new HashSet<String>();
    copy.addAll(administrativeUsers);
    return copy;
  }
  /**
   * Returns the database descriptors found using LDAP.
   * @return the database descriptors found using LDAP.
   * Returns the database descriptors found in the config.ldif.
   * @return the database descriptors found in the config.ldif.
   */
  public HashSet<DatabaseDescriptor> getDatabases()
  {
    return databases;
    HashSet<DatabaseDescriptor> copy = new HashSet<DatabaseDescriptor>();
    copy.addAll(databases);
    return copy;
  }
  /**
   * Returns the listener descriptors found using LDAP.
   * @return the listeners descriptors found using LDAP.
   * Returns the listener descriptors found in the config.ldif.
   * @return the listeners descriptors found in the config.ldif.
   */
  public HashSet<ListenerDescriptor> getListeners()
  {
    return listeners;
    HashSet<ListenerDescriptor> copy = new HashSet<ListenerDescriptor>();
    copy.addAll(listeners);
    return copy;
  }
  /**
@@ -794,22 +799,20 @@
    if (!isConfigBackend(id))
    {
      Set<String> baseDns = new TreeSet<String>();
      baseDns.addAll(getValues(entry, "ds-cfg-backend-base-dn"));
      Set<BaseDNDescriptor> replicas = new LinkedHashSet<BaseDNDescriptor>();
      Set<String> baseDns = getValues(entry, "ds-cfg-backend-base-dn");
      TreeSet<BaseDNDescriptor> replicas = new TreeSet<BaseDNDescriptor>();
      int nEntries = getEntryCount(ctx, id);
      DatabaseDescriptor db = new DatabaseDescriptor(id, replicas, nEntries);
      for (String baseDn : baseDns)
      {
        replicas.add(getBaseDNDescriptor(ctx, baseDn));
        BaseDNDescriptor rep = getBaseDNDescriptor(ctx, baseDn);
        rep.setDatabase(db);
        db.getBaseDns().add(rep);
      }
      DatabaseDescriptor db = new DatabaseDescriptor(id, replicas, nEntries);
      databases.add(db);
      for (BaseDNDescriptor rep: replicas)
      {
        rep.setDatabase(db);
      }
    }
  }
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/DatabaseDescriptor.java
@@ -27,7 +27,7 @@
package org.opends.statuspanel;
import java.util.Set;
import java.util.SortedSet;
/**
 * This class is used to represent a Database and is aimed to be used by the
@@ -36,7 +36,7 @@
public class DatabaseDescriptor
{
  private String backendID;
  private Set<BaseDNDescriptor> baseDns;
  private SortedSet<BaseDNDescriptor> baseDns;
  private int entries;
  /**
@@ -45,7 +45,8 @@
   * @param baseDns the base DNs associated with the Database.
   * @param entries the number of entries in the Database.
   */
  public DatabaseDescriptor(String backendID, Set<BaseDNDescriptor> baseDns,
  public DatabaseDescriptor(String backendID,
      SortedSet<BaseDNDescriptor> baseDns,
      int entries)
  {
    this.backendID = backendID;
@@ -66,7 +67,7 @@
   * Returns the Base DN objects associated with the database.
   * @return the Base DN objects associated with the database.
   */
  public Set<BaseDNDescriptor> getBaseDns()
  public SortedSet<BaseDNDescriptor> getBaseDns()
  {
    return baseDns;
  }
@@ -97,7 +98,7 @@
        if (equals)
        {
          equals = baseDns.equals(desc.getBaseDns());
          equals = desc.getBaseDns().equals(getBaseDns());
        }
      }
    }
@@ -116,8 +117,10 @@
    StringBuilder buf = new StringBuilder();
    for (BaseDNDescriptor rep: getBaseDns())
    {
      buf.append(rep.getDn());
      buf.append(rep.hashCode()+";");
    }
    return (getBackendID() + buf.toString() + getEntries()).hashCode();
    buf.append(getBackendID() + getEntries());
    return buf.toString().hashCode();
  }
}
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ListenerDescriptor.java
@@ -145,4 +145,21 @@
    return (getAddressPort() + getProtocolDescription() +
        getState()).hashCode();
  }
  /**
   * {@inheritDoc}
   */
  public boolean equals(Object o)
  {
    boolean equals = false;
    if (o == this)
    {
      equals = true;
    }
    else if (o instanceof ListenerDescriptor)
    {
      equals = hashCode() == o.hashCode();
    }
    return equals;
  }
}
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ServerStatusDescriptor.java
@@ -238,6 +238,11 @@
        if (equals)
        {
          equals = desc.getListeners().equals(getListeners());
        }
        if (equals)
        {
          equals = desc.getDatabases().equals(getDatabases());
        }
@@ -266,8 +271,7 @@
   */
  public int hashCode()
  {
    return status.hashCode() + openConnections + databases.hashCode() +
    listeners.hashCode() + administrativeUsers.hashCode() +
    return status.hashCode() + openConnections +
    (String.valueOf(
        installPath+openDSVersion+javaVersion+errorMsg+isAuthenticated)).
        hashCode();
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ServerStatusPooler.java
@@ -60,8 +60,8 @@
  private int nTriesWithErrorOnline;
  /* The pooling periods */
  private static final int OFFLINE_POOLING_PERIOD = 3000;
  private static final int ONLINE_POOLING_PERIOD = 5000;
  private static final int OFFLINE_POOLING_PERIOD = 6000;
  private static final int ONLINE_POOLING_PERIOD = 4000;
  /**
   * Default constructor.
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusCli.java
@@ -719,7 +719,7 @@
    }
    else
    {
      DatabasesTableModel databasesTableModel = new DatabasesTableModel();
      DatabasesTableModel databasesTableModel = new DatabasesTableModel(true);
      Set<BaseDNDescriptor> replicas = new HashSet<BaseDNDescriptor>();
      Set<DatabaseDescriptor> dbs = desc.getDatabases();
      for (DatabaseDescriptor db: dbs)
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ui/DatabasesTableModel.java
@@ -61,6 +61,17 @@
  };
  private int sortColumn = 0;
  private boolean sortAscending = true;
  private boolean displayReplicationInformation;
  /**
   * Constructor for this table model.
   * @param displayReplicationInformation whether to display replication
   * monitoring information or not.
   */
  public DatabasesTableModel(boolean displayReplicationInformation)
  {
    this.displayReplicationInformation = displayReplicationInformation;
  }
  /**
   * Sets the data for this table model.
@@ -296,7 +307,7 @@
   */
  public int getColumnCount()
  {
    return 6;
    return displayReplicationInformation ? 6 : 4;
  }
  /**
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ui/StatusPanelDialog.java
@@ -33,6 +33,7 @@
import java.awt.GridBagLayout;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
@@ -112,8 +113,10 @@
  private HashSet<JLabel> subsectionLabels = new HashSet<JLabel>();
  private DatabasesTableModel dbTableModel;
  private JTable dbTable;
  private DatabasesTableModel dbTableModelWithReplication;
  private DatabasesTableModel dbTableModelWithoutReplication;
  private JTable dbTableWithReplication;
  private JTable dbTableWithoutReplication;
  private ListenersTableModel listenersTableModel;
  private JTable listenersTable;
@@ -122,9 +125,6 @@
  private final String NOT_AVAILABLE = getMsg("not-available-label");
  private final int MAXIMAL_WIDTH = 1000;
  private final int MAXIMAL_HEIGHT = 1000;
  /**
   * ProgressDialog constructor.
   */
@@ -163,8 +163,8 @@
    int packedMinWidth = (int) getPreferredSize().getWidth();
    int packedMinHeight = (int) getPreferredSize().getHeight();
    int minWidth = Math.min(packedMinWidth, MAXIMAL_WIDTH);
    int minHeight = Math.min(packedMinHeight, MAXIMAL_HEIGHT);
    int minWidth = Math.min(packedMinWidth, getMaximalWidth());
    int minHeight = Math.min(packedMinHeight, getMaximalHeight());
    addComponentListener(new MinimumSizeComponentListener(this,
        minWidth, minHeight));
@@ -226,6 +226,18 @@
    if (mustRepack)
    {
      pack();
      int packedMinWidth = (int) getPreferredSize().getWidth();
      int packedMinHeight = (int) getPreferredSize().getHeight();
      int minWidth = Math.min(packedMinWidth, getMaximalWidth());
      int minHeight = Math.min(packedMinHeight, getMaximalHeight());
      if ((minWidth != packedMinWidth) || (minHeight != packedMinHeight))
      {
        setPreferredSize(new Dimension(minWidth, minHeight));
        pack();
      }
      lastPackDescriptor = lastDescriptor;
    }
  }
@@ -744,18 +756,35 @@
    p.add(createSubsectionTitle(getMsg("databases-title")), gbc);
    dbTableModel = new DatabasesTableModel();
    dbTable = UIFactory.makeSortableTable(dbTableModel,
    dbTableModelWithReplication = new DatabasesTableModel(true);
    dbTableModelWithoutReplication = new DatabasesTableModel(false);
    dbTableWithReplication =
      UIFactory.makeSortableTable(dbTableModelWithReplication,
        new DatabasesCellRenderer(),
        UIFactory.makeHeaderRenderer());
    toolTipManager.registerComponent(dbTable);
    toolTipManager.registerComponent(dbTableWithReplication);
    dbTableWithoutReplication =
      UIFactory.makeSortableTable(dbTableModelWithoutReplication,
        new DatabasesCellRenderer(),
        UIFactory.makeHeaderRenderer());
    toolTipManager.registerComponent(dbTableWithoutReplication);
    gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
    p.add(dbTable.getTableHeader(), gbc);
    int height = (int)dbTable.getTableHeader().getPreferredSize().getHeight();
    dbTable.setRowHeight(height);
    p.add(dbTableWithReplication.getTableHeader(), gbc);
    int height = (int)dbTableWithReplication.getTableHeader().
    getPreferredSize().getHeight();
    dbTableWithReplication.setRowHeight(height);
    gbc.insets.top = 0;
    p.add(dbTable, gbc);
    p.add(dbTableWithReplication, gbc);
    gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
    p.add(dbTableWithoutReplication.getTableHeader(), gbc);
    height = (int)dbTableWithoutReplication.getTableHeader().
    getPreferredSize().getHeight();
    dbTableWithoutReplication.setRowHeight(height);
    gbc.insets.top = 0;
    p.add(dbTableWithoutReplication, gbc);
    dbTableWithoutReplication.setVisible(false);
    gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
    lDbTableEmpty = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, "",
@@ -1063,12 +1092,16 @@
    {
      replicas.addAll(db.getBaseDns());
    }
    dbTableModel.setData(replicas);
    dbTableModelWithReplication.setData(replicas);
    dbTableModelWithoutReplication.setData(replicas);
    if (dbTableModel.getRowCount() == 0)
    if (dbTableModelWithReplication.getRowCount() == 0)
    {
      dbTable.setVisible(false);
      dbTable.getTableHeader().setVisible(false);
      dbTableWithoutReplication.setVisible(false);
      dbTableWithoutReplication.getTableHeader().setVisible(false);
      dbTableWithReplication.setVisible(false);
      dbTableWithReplication.getTableHeader().setVisible(false);
      lDbTableEmpty.setVisible(true);
      if (desc.getStatus() == ServerStatusDescriptor.ServerStatus.STARTED)
      {
@@ -1088,10 +1121,22 @@
    }
    else
    {
      dbTable.setVisible(true);
      dbTable.getTableHeader().setVisible(true);
      boolean replicated = false;
      for (BaseDNDescriptor suffix: replicas)
      {
        if (suffix.getType() == BaseDNDescriptor.Type.REPLICATED)
        {
          replicated = true;
        }
      }
      updateTableSizes(dbTableWithoutReplication);
      updateTableSizes(dbTableWithReplication);
      dbTableWithoutReplication.setVisible(!replicated);
      dbTableWithoutReplication.getTableHeader().setVisible(!replicated);
      dbTableWithReplication.setVisible(replicated);
      dbTableWithReplication.getTableHeader().setVisible(replicated);
      lDbTableEmpty.setVisible(false);
      updateTableSizes(dbTable);
    }
  }
@@ -1232,6 +1277,32 @@
    }
  }
  private int getMaximalWidth()
  {
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    boolean multipleScreen = screenSize.width / screenSize.height >= 2;
    if (multipleScreen)
    {
      return Math.min((screenSize.width/2) - 100, 1000);
    }
    else
    {
      return Math.min(screenSize.width - 100, 1000);
    }
  }
  /**
   * Returns the maximum height we allow this dialog to have after pack.
   * @return the maximum height we allow this dialog to have after pack.
   */
  private int getMaximalHeight()
  {
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    return Math.min(screenSize.height - 100, 800);
  }
  /**
   * Method written for testing purposes.
   * @param args the arguments to be passed to the test program.