| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.guitools.controlpanel.datamodel; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.monitors.TraditionalWorkQueueMonitor; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | /** |
| | | * The enumeration containing the different monitoring attributes that can be |
| | | * displayed in the monitoring panels. |
| | | */ |
| | | public enum BasicMonitoringAttributes implements MonitoringAttributes |
| | | { |
| | | /** |
| | | * Start Date. |
| | | */ |
| | | START_DATE(Message.EMPTY, ServerConstants.ATTR_START_TIME), |
| | | /** |
| | | * Current Date. |
| | | */ |
| | | CURRENT_DATE(Message.EMPTY, ServerConstants.ATTR_CURRENT_TIME), |
| | | /** |
| | | * Current Connections. |
| | | */ |
| | | CURRENT_CONNECTIONS(Message.EMPTY, ServerConstants.ATTR_CURRENT_CONNS), |
| | | /** |
| | | * Maximum Connections. |
| | | */ |
| | | MAX_CONNECTIONS(Message.EMPTY, ServerConstants.ATTR_MAX_CONNS), |
| | | /** |
| | | * Total Connections. |
| | | */ |
| | | TOTAL_CONNECTIONS(Message.EMPTY, ServerConstants.ATTR_TOTAL_CONNS), |
| | | /** |
| | | * Average Request Backlog. |
| | | */ |
| | | AVERAGE_REQUEST_BACKLOG(INFO_CTRL_PANEL_AVERAGE_REQUEST_BACKLOG.get(), |
| | | TraditionalWorkQueueMonitor.ATTR_AVERAGE_BACKLOG), |
| | | /** |
| | | * Max Request Backlog. |
| | | */ |
| | | MAX_REQUEST_BACKLOG(INFO_CTRL_PANEL_MAX_REQUEST_BACKLOG.get(), |
| | | TraditionalWorkQueueMonitor.ATTR_MAX_BACKLOG), |
| | | /** |
| | | * Current Request Backlog. |
| | | */ |
| | | CURRENT_REQUEST_BACKLOG(INFO_CTRL_PANEL_CURRENT_REQUEST_BACKLOG.get(), |
| | | TraditionalWorkQueueMonitor.ATTR_CURRENT_BACKLOG), |
| | | /** |
| | | * Requests submitted. |
| | | */ |
| | | REQUESTS_SUBMITTED(INFO_CTRL_PANEL_REQUESTS_SUBMITTED.get(), |
| | | TraditionalWorkQueueMonitor.ATTR_OPS_SUBMITTED), |
| | | /** |
| | | * Requests rejected. |
| | | */ |
| | | REQUESTS_REJECTED(INFO_CTRL_PANEL_REQUESTS_REJECTED.get(), |
| | | TraditionalWorkQueueMonitor.ATTR_OPS_REJECTED_QUEUE_FULL), |
| | | /** |
| | | * Entry cache Hits. |
| | | */ |
| | | ENTRY_CACHE_HITS(INFO_CTRL_PANEL_ENTRY_CACHE_HITS.get(), |
| | | "entryCacheHits"), |
| | | /** |
| | | * Current entry cache count. |
| | | */ |
| | | CURRENT_ENTRY_CACHE_COUNT(INFO_CTRL_PANEL_CURRENT_ENTRY_CACHE_COUNT.get(), |
| | | "currentEntryCacheCount"), |
| | | /** |
| | | * Entry cache tries. |
| | | */ |
| | | ENTRY_CACHE_TRIES(INFO_CTRL_PANEL_ENTRY_CACHE_TRIES.get(), |
| | | "entryCacheTries"), |
| | | /** |
| | | * Entry cache hit ratio. |
| | | */ |
| | | ENTRY_CACHE_HIT_RATIO(INFO_CTRL_PANEL_ENTRY_CACHE_HIT_RATIO.get(), |
| | | "entryCacheHitRatio"), |
| | | /** |
| | | * Entry cache current size. |
| | | */ |
| | | CURRENT_ENTRY_CACHE_SIZE(INFO_CTRL_PANEL_CURRENT_ENTRY_CACHE_SIZE.get(), |
| | | "currentEntryCacheSize"), |
| | | /** |
| | | * Entry cache max size. |
| | | */ |
| | | MAX_ENTRY_CACHE_SIZE(INFO_CTRL_PANEL_MAX_ENTRY_CACHE_SIZE.get(), |
| | | "maxEntryCacheSize"), |
| | | /** |
| | | * Entry cache max count. |
| | | */ |
| | | MAX_ENTRY_CACHE_COUNT(INFO_CTRL_PANEL_MAX_ENTRY_CACHE_COUNT.get(), |
| | | "maxEntryCacheCount"), |
| | | /** |
| | | * Available CPUs. |
| | | */ |
| | | AVAILABLE_CPUS(INFO_CTRL_PANEL_AVAILABLE_CPUS.get(), |
| | | "availableCPUs"), |
| | | /** |
| | | * System Name. |
| | | */ |
| | | SYSTEM_NAME(INFO_CTRL_PANEL_SYSTEM_NAME.get(), |
| | | "systemName"), |
| | | /** |
| | | * Operating System. |
| | | */ |
| | | OPERATING_SYSTEM(INFO_CTRL_PANEL_OPERATING_SYSTEM.get(), |
| | | "operatingSystem"), |
| | | /** |
| | | * Free used memory. |
| | | */ |
| | | FREE_USED_MEMORY(INFO_CTRL_PANEL_FREE_USED_MEMORY.get(), |
| | | "freeUsedMemory"), |
| | | /** |
| | | * Max memory. |
| | | */ |
| | | MAX_MEMORY(INFO_CTRL_PANEL_MAX_MEMORY.get(), |
| | | "maxMemory"), |
| | | /** |
| | | * Used memory. |
| | | */ |
| | | USED_MEMORY(INFO_CTRL_PANEL_USED_MEMORY.get(), |
| | | "usedMemory"), |
| | | /** |
| | | * Class path. |
| | | */ |
| | | CLASS_PATH(INFO_CTRL_PANEL_CLASS_PATH.get(), |
| | | "classPath"), |
| | | /** |
| | | * Java Vendor. |
| | | */ |
| | | JAVA_VENDOR(INFO_CTRL_PANEL_JAVA_VENDOR.get(), |
| | | "javaVendor"), |
| | | /** |
| | | * JVM Vendor. |
| | | */ |
| | | JVM_VENDOR(INFO_CTRL_PANEL_JVM_VENDOR.get(), |
| | | "javaVendor"), |
| | | /** |
| | | * Java Version. |
| | | */ |
| | | JAVA_VERSION(INFO_CTRL_PANEL_JAVA_VERSION.get(), |
| | | "javaVersion"), |
| | | /** |
| | | * JVM Version. |
| | | */ |
| | | JVM_VERSION(INFO_CTRL_PANEL_JVM_VERSION.get(), |
| | | "jvmVersion"), |
| | | /** |
| | | * JVM Architecture. |
| | | */ |
| | | JVM_ARCHITECTURE(INFO_CTRL_PANEL_JVM_ARCHITECTURE.get(), |
| | | "jvmArchitecture"), |
| | | /** |
| | | * JVM Arguments. |
| | | */ |
| | | JVM_ARGUMENTS(INFO_CTRL_PANEL_JVM_ARGUMENTS.get(), |
| | | "jvmArguments"), |
| | | /** |
| | | * Add Request. |
| | | */ |
| | | ADD_REQUESTS(INFO_CTRL_PANEL_ADD_REQUESTS_LABEL.get(), |
| | | "addRequests"), |
| | | /** |
| | | * Add Responses. |
| | | */ |
| | | ADD_RESPONSES(INFO_CTRL_PANEL_ADD_RESPONSES_LABEL.get(), |
| | | "addResponses"), |
| | | /** |
| | | * Bind Request. |
| | | */ |
| | | BIND_REQUESTS(INFO_CTRL_PANEL_BIND_REQUESTS_LABEL.get(), |
| | | "bindRequests"), |
| | | /** |
| | | * Bind Responses. |
| | | */ |
| | | BIND_RESPONSES(INFO_CTRL_PANEL_BIND_RESPONSES_LABEL.get(), |
| | | "bindResponses"), |
| | | /** |
| | | * Compare Requests. |
| | | */ |
| | | COMPARE_REQUESTS(INFO_CTRL_PANEL_COMPARE_REQUESTS_LABEL.get(), |
| | | "compareRequests"), |
| | | /** |
| | | * Compare Responses. |
| | | */ |
| | | COMPARE_RESPONSES(INFO_CTRL_PANEL_COMPARE_RESPONSES_LABEL.get(), |
| | | "compareResponses"), |
| | | /** |
| | | * Delete Request. |
| | | */ |
| | | DELETE_REQUESTS(INFO_CTRL_PANEL_DELETE_REQUESTS_LABEL.get(), |
| | | "deleteRequests"), |
| | | /** |
| | | * Delete Responses. |
| | | */ |
| | | DELETE_RESPONSES(INFO_CTRL_PANEL_DELETE_RESPONSES_LABEL.get(), |
| | | "deleteResponses"), |
| | | /** |
| | | * Extended Request. |
| | | */ |
| | | EXTENDED_REQUESTS(INFO_CTRL_PANEL_EXTENDED_REQUESTS_LABEL.get(), |
| | | "extendedRequests"), |
| | | /** |
| | | * Extended Responses. |
| | | */ |
| | | EXTENDED_RESPONSES(INFO_CTRL_PANEL_EXTENDED_RESPONSES_LABEL.get(), |
| | | "extendedResponses"), |
| | | /** |
| | | * Modify DN Request. |
| | | */ |
| | | MOD_DN_REQUESTS(INFO_CTRL_PANEL_MOD_DN_REQUESTS_LABEL.get(), |
| | | "modifyDNRequests"), |
| | | /** |
| | | * Modify DN Responses. |
| | | */ |
| | | MOD_DN_RESPONSES(INFO_CTRL_PANEL_MOD_DN_RESPONSES_LABEL.get(), |
| | | "modifyDNResponses"), |
| | | /** |
| | | * Modify Request. |
| | | */ |
| | | MOD_REQUESTS(INFO_CTRL_PANEL_MOD_REQUESTS_LABEL.get(), |
| | | "modifyRequests"), |
| | | /** |
| | | * Modify Responses. |
| | | */ |
| | | MOD_RESPONSES(INFO_CTRL_PANEL_MOD_RESPONSES_LABEL.get(), |
| | | "modifyResponses"), |
| | | /** |
| | | * Search Request. |
| | | */ |
| | | SEARCH_REQUESTS(INFO_CTRL_PANEL_SEARCH_REQUESTS_LABEL.get(), |
| | | "searchRequests"), |
| | | /** |
| | | * Searches Done. |
| | | */ |
| | | SEARCH_DONE(INFO_CTRL_PANEL_SEARCH_DONE_LABEL.get(), |
| | | "searchResultsDone"), |
| | | /** |
| | | * Unbind Request. |
| | | */ |
| | | UNBIND_REQUESTS(INFO_CTRL_PANEL_UNBIND_REQUESTS_LABEL.get(), |
| | | "unbindRequests"),; |
| | | |
| | | static |
| | | { |
| | | // Do this here, since static references do not work if this is done |
| | | // in the constructor. |
| | | for (BasicMonitoringAttributes attr : BasicMonitoringAttributes.values()) |
| | | { |
| | | attr.calculateProperties(); |
| | | } |
| | | } |
| | | |
| | | private Message msg; |
| | | private String attributeName; |
| | | private boolean isAborted; |
| | | private boolean isNumeric; |
| | | private boolean isGMTDate; |
| | | private boolean isValueInBytes; |
| | | private boolean canHaveAverage; |
| | | private boolean isTime; |
| | | |
| | | private BasicMonitoringAttributes(Message msg, String attributeName) |
| | | { |
| | | this.msg = msg; |
| | | this.attributeName = attributeName; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Message getMessage() |
| | | { |
| | | return msg; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public String getAttributeName() |
| | | { |
| | | return attributeName; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isAborted() |
| | | { |
| | | return isAborted; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isNumeric() |
| | | { |
| | | return isNumeric; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isTime() |
| | | { |
| | | return isTime; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isGMTDate() |
| | | { |
| | | return isGMTDate; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isValueInBytes() |
| | | { |
| | | return isValueInBytes; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean canHaveAverage() |
| | | { |
| | | return canHaveAverage; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isNumericDate() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | private void calculateProperties() |
| | | { |
| | | isAborted = attributeName.indexOf("ds-mon-aborted-") == 0; |
| | | |
| | | canHaveAverage = attributeName.endsWith("total-count") || |
| | | attributeName.endsWith("Requests") || |
| | | attributeName.endsWith("Responses") || |
| | | this == SEARCH_DONE; |
| | | |
| | | isGMTDate = this == START_DATE || |
| | | this == CURRENT_DATE; |
| | | |
| | | isValueInBytes = this == FREE_USED_MEMORY || |
| | | this == MAX_MEMORY || |
| | | this == USED_MEMORY; |
| | | |
| | | isTime = attributeName.indexOf("time") != -1; |
| | | |
| | | isNumeric = |
| | | !this.isGMTDate() && |
| | | this != SYSTEM_NAME && |
| | | this != OPERATING_SYSTEM && |
| | | this != CLASS_PATH && |
| | | this != JAVA_VENDOR && |
| | | this != JVM_VENDOR && |
| | | this != JAVA_VERSION && |
| | | this != JVM_VERSION && |
| | | this != JVM_ARCHITECTURE && |
| | | this != JVM_ARGUMENTS; |
| | | } |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.datamodel; |
| | |
| | | |
| | | import java.net.InetAddress; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.Set; |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | | |
| | |
| | | */ |
| | | public class ConnectionHandlerDescriptor |
| | | { |
| | | private Set<CustomSearchResult> monitoringEntries = Collections.emptySet(); |
| | | |
| | | /** |
| | | * Enumeration used to represent the state of the listener. |
| | | */ |
| | |
| | | * @param protocol the protocol of the listener. |
| | | * @param state the state of the connection handler (enabled, disabled, etc.). |
| | | * @param name the name of the listener. |
| | | * @param monitoringEntries the LDAP entries containing the monitoring |
| | | * information. |
| | | */ |
| | | public ConnectionHandlerDescriptor(Collection<InetAddress> addresses, |
| | | int port, Protocol protocol, State state, String name) |
| | | int port, Protocol protocol, State state, String name, |
| | | Set<CustomSearchResult> monitoringEntries) |
| | | { |
| | | this.addresses.addAll(addresses); |
| | | this.port = port; |
| | | this.protocol = protocol; |
| | | this.state = state; |
| | | this.name = name; |
| | | this.monitoringEntries = Collections.unmodifiableSet(monitoringEntries); |
| | | |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.append(getProtocol() + " " + getState() + " "); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the monitoring entries. |
| | | * @return the monitoring entries. |
| | | */ |
| | | public Set<CustomSearchResult> getMonitoringEntries() |
| | | { |
| | | return monitoringEntries; |
| | | } |
| | | |
| | | /** |
| | | * Sets the monitoring entries. |
| | | * @param monitoringEntries the monitoring entries. |
| | | */ |
| | | public void setMonitoringEntries(Set<CustomSearchResult> monitoringEntries) |
| | | { |
| | | this.monitoringEntries = Collections.unmodifiableSet(monitoringEntries); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public int hashCode() |
| | |
| | | else if (o instanceof ConnectionHandlerDescriptor) |
| | | { |
| | | equals = toString.equals(o.toString()); |
| | | if (equals) |
| | | { |
| | | ConnectionHandlerDescriptor ch = |
| | | (ConnectionHandlerDescriptor)o; |
| | | // Compare monitoring entries |
| | | equals = (getMonitoringEntries().equals(ch.getMonitoringEntries())); |
| | | } |
| | | } |
| | | return equals; |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.guitools.controlpanel.datamodel; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | |
| | | import java.net.InetAddress; |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.Set; |
| | | |
| | | import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor. |
| | | Protocol; |
| | | import org.opends.messages.Message; |
| | | |
| | | /** |
| | | * The table model used to display the monitoring information of connection |
| | | * handlers. |
| | | * |
| | | */ |
| | | public class ConnectionHandlersMonitoringTableModel extends |
| | | MonitoringTableModel<ConnectionHandlerDescriptor, |
| | | AddressConnectionHandlerDescriptor> |
| | | { |
| | | private static final long serialVersionUID = -8891998773191495L; |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected Set<AddressConnectionHandlerDescriptor> convertToInternalData( |
| | | Set<ConnectionHandlerDescriptor> newData) |
| | | { |
| | | Set<AddressConnectionHandlerDescriptor> newAddresses = |
| | | new HashSet<AddressConnectionHandlerDescriptor>(); |
| | | for (ConnectionHandlerDescriptor ch : newData) |
| | | { |
| | | if (ch.getAddresses().isEmpty()) |
| | | { |
| | | newAddresses.add(new AddressConnectionHandlerDescriptor(ch, null, |
| | | getMonitoringEntry(null, ch))); |
| | | } |
| | | else |
| | | { |
| | | for (InetAddress address : ch.getAddresses()) |
| | | { |
| | | newAddresses.add(new AddressConnectionHandlerDescriptor(ch, address, |
| | | getMonitoringEntry(address, ch))); |
| | | } |
| | | } |
| | | } |
| | | return newAddresses; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public int compare(AddressConnectionHandlerDescriptor desc1, |
| | | AddressConnectionHandlerDescriptor desc2) |
| | | { |
| | | int result; |
| | | ArrayList<Integer> possibleResults = new ArrayList<Integer>(); |
| | | |
| | | possibleResults.add(compareNames(desc1, desc2)); |
| | | possibleResults.addAll(getMonitoringPossibleResults( |
| | | desc1.getMonitoringEntry(), desc2.getMonitoringEntry())); |
| | | |
| | | result = possibleResults.get(getSortColumn()); |
| | | if (result == 0) |
| | | { |
| | | for (int i : possibleResults) |
| | | { |
| | | if (i != 0) |
| | | { |
| | | result = i; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (!isSortAscending()) |
| | | { |
| | | result = -result; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private int compareNames(AddressConnectionHandlerDescriptor ach1, |
| | | AddressConnectionHandlerDescriptor ach2) |
| | | { |
| | | int compare = 0; |
| | | boolean addressEqual = false; |
| | | if (ach1.getAddress() == null) |
| | | { |
| | | if (ach2.getAddress() == null) |
| | | { |
| | | addressEqual = true; |
| | | } |
| | | } |
| | | else if (ach2.getAddress() != null) |
| | | { |
| | | addressEqual = ach1.getAddress().equals(ach2.getAddress()); |
| | | } |
| | | if (addressEqual) |
| | | { |
| | | Integer port1 = new Integer(ach1.getConnectionHandler().getPort()); |
| | | Integer port2 = new Integer(ach2.getConnectionHandler().getPort()); |
| | | compare = port1.compareTo(port2); |
| | | } |
| | | else |
| | | { |
| | | compare = getName(ach1).compareTo(getName(ach2)); |
| | | } |
| | | return compare; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected CustomSearchResult getMonitoringEntry( |
| | | AddressConnectionHandlerDescriptor ach) |
| | | { |
| | | return ach.getMonitoringEntry(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected String getName(AddressConnectionHandlerDescriptor ach) |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | ConnectionHandlerDescriptor ch = ach.getConnectionHandler(); |
| | | if (ch.getProtocol() == Protocol.ADMINISTRATION_CONNECTOR) |
| | | { |
| | | sb.append(INFO_CTRL_PANEL_ADMINISTRATION_CONNECTOR_NAME.get( |
| | | ch.getPort())); |
| | | } |
| | | else |
| | | { |
| | | if (ach.getAddress() != null) |
| | | { |
| | | sb.append(ach.getAddress().getHostName()+":"+ch.getPort()); |
| | | } |
| | | else |
| | | { |
| | | sb.append(ch.getPort()); |
| | | } |
| | | sb.append(" - "); |
| | | switch (ch.getProtocol()) |
| | | { |
| | | case OTHER: |
| | | sb.append(ch.getName()); |
| | | break; |
| | | default: |
| | | sb.append(ch.getProtocol().getDisplayMessage().toString()); |
| | | break; |
| | | } |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | |
| | | private CustomSearchResult getMonitoringEntry(InetAddress address, |
| | | ConnectionHandlerDescriptor cch) |
| | | { |
| | | CustomSearchResult monitoringEntry = null; |
| | | for (CustomSearchResult sr : cch.getMonitoringEntries()) |
| | | { |
| | | String cn = (String)getFirstMonitoringValue(sr, "cn"); |
| | | if (cn != null) |
| | | { |
| | | if (address == null) |
| | | { |
| | | monitoringEntry = sr; |
| | | break; |
| | | } |
| | | else |
| | | { |
| | | if (cn.endsWith( |
| | | " "+address.getHostAddress()+" port "+cch.getPort()+ |
| | | " Statistics") || |
| | | cn.endsWith( |
| | | " "+address.getHostName()+" port "+cch.getPort()+ |
| | | " Statistics")) |
| | | { |
| | | monitoringEntry = sr; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return monitoringEntry; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected Message getNameHeader() |
| | | { |
| | | return INFO_CTRL_PANEL_CONNECTION_HANDLER_HEADER.get(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * The table model has one line per address, this object represents that |
| | | * address and all the associated monitoring information. |
| | | * |
| | | */ |
| | | class AddressConnectionHandlerDescriptor |
| | | { |
| | | private ConnectionHandlerDescriptor ch; |
| | | private InetAddress address; |
| | | private CustomSearchResult monitoringEntry; |
| | | private int hashCode; |
| | | |
| | | /** |
| | | * Constructor of this data structure. |
| | | * @param ch the connection handler descriptor. |
| | | * @param address the address. |
| | | * @param monitoringEntry the monitoringEntry. |
| | | */ |
| | | public AddressConnectionHandlerDescriptor( |
| | | ConnectionHandlerDescriptor ch, |
| | | InetAddress address, |
| | | CustomSearchResult monitoringEntry) |
| | | { |
| | | this.ch = ch; |
| | | this.address = address; |
| | | this.monitoringEntry = monitoringEntry; |
| | | |
| | | if (address != null) |
| | | { |
| | | hashCode = ch.hashCode() + address.hashCode(); |
| | | } |
| | | else |
| | | { |
| | | hashCode = ch.hashCode(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns the address. |
| | | * @return the address. |
| | | */ |
| | | public InetAddress getAddress() |
| | | { |
| | | return address; |
| | | } |
| | | |
| | | /** |
| | | * Returns the connection handler descriptor. |
| | | * @return the connection handler descriptor. |
| | | */ |
| | | public ConnectionHandlerDescriptor getConnectionHandler() |
| | | { |
| | | return ch; |
| | | } |
| | | |
| | | /** |
| | | * Returns the monitoring entry. |
| | | * @return the monitoring entry. |
| | | */ |
| | | public CustomSearchResult getMonitoringEntry() |
| | | { |
| | | return monitoringEntry; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public int hashCode() |
| | | { |
| | | return hashCode; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean equals(Object o) |
| | | { |
| | | boolean equals = false; |
| | | if (o != this) |
| | | { |
| | | if (o instanceof AddressConnectionHandlerDescriptor) |
| | | { |
| | | AddressConnectionHandlerDescriptor ach = |
| | | (AddressConnectionHandlerDescriptor)o; |
| | | if (ach.getAddress() == null) |
| | | { |
| | | equals = getAddress() == null; |
| | | } |
| | | else if (getAddress() == null) |
| | | { |
| | | equals = false; |
| | | } |
| | | else |
| | | { |
| | | equals = ach.getAddress().equals(getAddress()); |
| | | } |
| | | if (equals) |
| | | { |
| | | equals = ach.getConnectionHandler().equals(getConnectionHandler()); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | equals = true; |
| | | } |
| | | return equals; |
| | | } |
| | | } |
| | |
| | | desc.setAuthenticated(reader instanceof ConfigFromDirContext); |
| | | desc.setJavaVersion(reader.getJavaVersion()); |
| | | desc.setOpenConnections(reader.getOpenConnections()); |
| | | if (reader instanceof ConfigFromDirContext) |
| | | { |
| | | ConfigFromDirContext rCtx = (ConfigFromDirContext)reader; |
| | | desc.setRootMonitor(rCtx.getRootMonitor()); |
| | | desc.setEntryCachesMonitor(rCtx.getEntryCaches()); |
| | | desc.setJvmMemoryUsageMonitor(rCtx.getJvmMemoryUsage()); |
| | | desc.setSystemInformationMonitor(rCtx.getSystemInformation()); |
| | | desc.setWorkQueueMonitor(rCtx.getWorkQueue()); |
| | | } |
| | | } |
| | | else |
| | | { |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.guitools.controlpanel.datamodel; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Comparator; |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.Set; |
| | | import java.util.TreeSet; |
| | | |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.messages.Message; |
| | | |
| | | /** |
| | | * The abstract table model used to display all the network groups. |
| | | */ |
| | | public class DBEnvironmentMonitoringTableModel extends SortableTableModel |
| | | implements Comparator<BackendDescriptor> |
| | | { |
| | | private static final long serialVersionUID = 548035716525600536L; |
| | | private Set<BackendDescriptor> data = new HashSet<BackendDescriptor>(); |
| | | private ArrayList<String[]> dataArray = new ArrayList<String[]>(); |
| | | private ArrayList<BackendDescriptor> dataSourceArray = |
| | | new ArrayList<BackendDescriptor>(); |
| | | |
| | | private String[] columnNames = {}; |
| | | private Message NO_VALUE_SET = INFO_CTRL_PANEL_NO_MONITORING_VALUE.get(); |
| | | private Message NOT_IMPLEMENTED = INFO_CTRL_PANEL_NOT_IMPLEMENTED.get(); |
| | | |
| | | |
| | | /** |
| | | * The operations to be displayed. |
| | | */ |
| | | private LinkedHashSet<String> attributes = new LinkedHashSet<String>(); |
| | | /** |
| | | * The sort column of the table. |
| | | */ |
| | | private int sortColumn = 0; |
| | | /** |
| | | * Whether the sorting is ascending or descending. |
| | | */ |
| | | private boolean sortAscending = true; |
| | | |
| | | /** |
| | | * Sets the data for this table model. |
| | | * @param newData the data for this table model. |
| | | */ |
| | | public void setData(Set<BackendDescriptor> newData) |
| | | { |
| | | if (!newData.equals(data)) |
| | | { |
| | | data.clear(); |
| | | data.addAll(newData); |
| | | updateDataArray(); |
| | | fireTableDataChanged(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Updates the table model contents and sorts its contents depending on the |
| | | * sort options set by the user. |
| | | */ |
| | | public void forceResort() |
| | | { |
| | | updateDataArray(); |
| | | fireTableDataChanged(); |
| | | } |
| | | |
| | | /** |
| | | * Updates the table model contents, sorts its contents depending on the |
| | | * sort options set by the user and updates the column structure. |
| | | */ |
| | | public void forceDataStructureChange() |
| | | { |
| | | updateDataArray(); |
| | | fireTableStructureChanged(); |
| | | fireTableDataChanged(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public int getColumnCount() |
| | | { |
| | | return columnNames.length; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public int getRowCount() |
| | | { |
| | | return dataArray.size(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Object getValueAt(int row, int col) |
| | | { |
| | | return dataArray.get(row)[col]; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public String getColumnName(int col) { |
| | | return columnNames[col]; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public int compare(BackendDescriptor desc1, BackendDescriptor desc2) |
| | | { |
| | | int result; |
| | | ArrayList<Integer> possibleResults = new ArrayList<Integer>(); |
| | | |
| | | possibleResults.add(getName(desc1).compareTo(getName(desc2))); |
| | | for (String attrName : attributes) |
| | | { |
| | | int possibleResult; |
| | | if (desc1.getMonitoringEntry() == null) |
| | | { |
| | | if (desc2.getMonitoringEntry() == null) |
| | | { |
| | | possibleResult = 0; |
| | | } |
| | | else |
| | | { |
| | | possibleResult = -1; |
| | | } |
| | | } |
| | | else if (desc2.getMonitoringEntry() == null) |
| | | { |
| | | possibleResult = 1; |
| | | } |
| | | else |
| | | { |
| | | Object v1 = null; |
| | | Object v2 = null; |
| | | |
| | | for (String attr : desc1.getMonitoringEntry().getAttributeNames()) |
| | | { |
| | | if (attr.equalsIgnoreCase(attrName)) |
| | | { |
| | | v1 = getFirstMonitoringValue(desc1.getMonitoringEntry(), attrName); |
| | | break; |
| | | } |
| | | } |
| | | for (String attr : desc2.getMonitoringEntry().getAttributeNames()) |
| | | { |
| | | if (attr.equalsIgnoreCase(attrName)) |
| | | { |
| | | v2 = getFirstMonitoringValue(desc2.getMonitoringEntry(), attrName); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (v1 == null) |
| | | { |
| | | if (v2 == null) |
| | | { |
| | | possibleResult = 0; |
| | | } |
| | | else |
| | | { |
| | | possibleResult = -1; |
| | | } |
| | | } |
| | | else if (v2 == null) |
| | | { |
| | | possibleResult = 1; |
| | | } |
| | | else |
| | | { |
| | | if (v1 instanceof Number) |
| | | { |
| | | if ((v1 instanceof Double) || (v2 instanceof Double)) |
| | | { |
| | | double n1 = ((Number)v1).doubleValue(); |
| | | double n2 = ((Number)v2).doubleValue(); |
| | | if (n1 > n2) |
| | | { |
| | | possibleResult = 1; |
| | | } |
| | | else if (n1 < n2) |
| | | { |
| | | possibleResult = -1; |
| | | } |
| | | else |
| | | { |
| | | possibleResult = 0; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | long n1 = ((Number)v1).longValue(); |
| | | long n2 = ((Number)v2).longValue(); |
| | | if (n1 > n2) |
| | | { |
| | | possibleResult = 1; |
| | | } |
| | | else if (n1 < n2) |
| | | { |
| | | possibleResult = -1; |
| | | } |
| | | else |
| | | { |
| | | possibleResult = 0; |
| | | } |
| | | } |
| | | } |
| | | else if (v2 instanceof Number) |
| | | { |
| | | possibleResult = -1; |
| | | } |
| | | else |
| | | { |
| | | possibleResult = v1.toString().compareTo(v2.toString()); |
| | | } |
| | | } |
| | | } |
| | | possibleResults.add(possibleResult); |
| | | } |
| | | |
| | | result = possibleResults.get(getSortColumn()); |
| | | if (result == 0) |
| | | { |
| | | for (int i : possibleResults) |
| | | { |
| | | if (i != 0) |
| | | { |
| | | result = i; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (!isSortAscending()) |
| | | { |
| | | result = -result; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * Returns whether the sort is ascending or descending. |
| | | * @return <CODE>true</CODE> if the sort is ascending and <CODE>false</CODE> |
| | | * otherwise. |
| | | */ |
| | | public boolean isSortAscending() |
| | | { |
| | | return sortAscending; |
| | | } |
| | | |
| | | /** |
| | | * Sets whether to sort ascending of descending. |
| | | * @param sortAscending whether to sort ascending or descending. |
| | | */ |
| | | public void setSortAscending(boolean sortAscending) |
| | | { |
| | | this.sortAscending = sortAscending; |
| | | } |
| | | |
| | | /** |
| | | * Returns the column index used to sort. |
| | | * @return the column index used to sort. |
| | | */ |
| | | public int getSortColumn() |
| | | { |
| | | return sortColumn; |
| | | } |
| | | |
| | | /** |
| | | * Sets the column index used to sort. |
| | | * @param sortColumn column index used to sort.. |
| | | */ |
| | | public void setSortColumn(int sortColumn) |
| | | { |
| | | this.sortColumn = sortColumn; |
| | | } |
| | | |
| | | /** |
| | | * Returns the operations displayed by this table model. |
| | | * @return the operations displayed by this table model. |
| | | */ |
| | | public Collection<String> getAttributes() |
| | | { |
| | | return attributes; |
| | | } |
| | | |
| | | /** |
| | | * Sets the operations displayed by this table model. |
| | | * @param operations the operations displayed by this table model. |
| | | */ |
| | | public void setAttributes(LinkedHashSet<String> operations) |
| | | { |
| | | this.attributes.clear(); |
| | | this.attributes.addAll(operations); |
| | | columnNames = new String[operations.size() + 1]; |
| | | columnNames[0] = INFO_CTRL_PANEL_DB_HEADER.get().toString(); |
| | | int i = 1; |
| | | for (String operation : operations) |
| | | { |
| | | columnNames[i] = operation; |
| | | i++; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Updates the array data. This includes resorting it. |
| | | */ |
| | | private void updateDataArray() |
| | | { |
| | | TreeSet<BackendDescriptor> sortedSet = new TreeSet<BackendDescriptor>(this); |
| | | sortedSet.addAll(data); |
| | | dataArray.clear(); |
| | | dataSourceArray.clear(); |
| | | for (BackendDescriptor ach : sortedSet) |
| | | { |
| | | String[] s = getLine(ach); |
| | | dataArray.add(s); |
| | | dataSourceArray.add(ach); |
| | | } |
| | | |
| | | // Add the total: always at the end |
| | | |
| | | String[] line = new String[attributes.size() + 1]; |
| | | line[0] = "<html><b>"+INFO_CTRL_PANEL_TOTAL_LABEL.get().toString()+ |
| | | "</b>"; |
| | | for (int i=1; i<line.length; i++) |
| | | { |
| | | boolean valueSet = false; |
| | | boolean notImplemented = false; |
| | | long totalValue = 0; |
| | | for (int j=0; j<dataArray.size(); j++) |
| | | { |
| | | String[] l = dataArray.get(j); |
| | | String value = l[i]; |
| | | try |
| | | { |
| | | long v = Long.parseLong(value); |
| | | totalValue += v; |
| | | valueSet = true; |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | try |
| | | { |
| | | double v = Double.parseDouble(value); |
| | | totalValue += v; |
| | | valueSet = true; |
| | | } |
| | | catch (Throwable t2) |
| | | { |
| | | notImplemented = NOT_IMPLEMENTED.toString().equals(value); |
| | | } |
| | | } |
| | | } |
| | | if (notImplemented) |
| | | { |
| | | line[i] = NOT_IMPLEMENTED.toString(); |
| | | } |
| | | else if (valueSet) |
| | | { |
| | | line[i] = String.valueOf(totalValue); |
| | | } |
| | | else |
| | | { |
| | | line[i] = NO_VALUE_SET.toString(); |
| | | } |
| | | } |
| | | dataArray.add(line); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected String[] getColumnNames() |
| | | { |
| | | return columnNames; |
| | | } |
| | | |
| | | /** |
| | | * Returns the label to be used for the provided backend. |
| | | * @param backend the backend. |
| | | * @return the label to be used for the provided backend. |
| | | */ |
| | | protected String getName(BackendDescriptor backend) |
| | | { |
| | | return backend.getBackendID(); |
| | | } |
| | | |
| | | /** |
| | | * Returns the monitoring entry associated with the provided backend. |
| | | * @param backend the backend. |
| | | * @return the monitoring entry associated with the provided backend. Returns |
| | | * <CODE>null</CODE> if there is no monitoring entry associated. |
| | | */ |
| | | protected CustomSearchResult getMonitoringEntry( |
| | | BackendDescriptor backend) |
| | | { |
| | | return backend.getMonitoringEntry(); |
| | | } |
| | | |
| | | private String[] getLine(BackendDescriptor backend) |
| | | { |
| | | String[] line = new String[attributes.size() + 1]; |
| | | line[0] = getName(backend); |
| | | int i = 1; |
| | | CustomSearchResult monitoringEntry = getMonitoringEntry(backend); |
| | | for (String attr : attributes) |
| | | { |
| | | Object o = getFirstMonitoringValue(monitoringEntry, attr); |
| | | if (o == null) |
| | | { |
| | | line[i] = NO_VALUE_SET.toString(); |
| | | } |
| | | else |
| | | { |
| | | line[i] = o.toString(); |
| | | } |
| | | i++; |
| | | } |
| | | return line; |
| | | } |
| | | |
| | | /** |
| | | * Returns the first value for a given attribute in the provided entry. |
| | | * @param sr the entry. |
| | | * @param attrName the attribute name. |
| | | * @return the first value for a given attribute in the provided entry. |
| | | */ |
| | | protected Object getFirstMonitoringValue(CustomSearchResult sr, |
| | | String attrName) |
| | | { |
| | | return Utilities.getFirstMonitoringValue(sr, attrName); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.guitools.controlpanel.datamodel; |
| | | |
| | | import org.opends.messages.Message; |
| | | |
| | | /** |
| | | * An interface defining the different methods required by the UI components |
| | | * to display monitoring attributes data. |
| | | * |
| | | */ |
| | | public interface MonitoringAttributes |
| | | { |
| | | /** |
| | | * Returns the message associated with the attribute (basically is the |
| | | * localized name of the operation associated with the attribute). |
| | | * @return the message associated with the attribute. |
| | | */ |
| | | public Message getMessage(); |
| | | |
| | | /** |
| | | * Returns the name of the attribute. |
| | | * @return the name of the attribute. |
| | | */ |
| | | public String getAttributeName(); |
| | | |
| | | /** |
| | | * Tells whether this is the number of aborted operations. |
| | | * @return <CODE>true</CODE> if this corresponds to the number of aborted |
| | | * operations and <CODE>false</CODE> otherwise. |
| | | */ |
| | | public boolean isAborted(); |
| | | |
| | | /** |
| | | * Return whether this attribute contains a numeric value or not. |
| | | * @return <CODE>true</CODE> if the value is numeric and <CODE>false</CODE> |
| | | * otherwise. |
| | | */ |
| | | public boolean isNumeric(); |
| | | |
| | | /** |
| | | * Return whether this attribute contains a time value or not. |
| | | * @return <CODE>true</CODE> if the value is a time and <CODE>false</CODE> |
| | | * otherwise. |
| | | */ |
| | | public boolean isTime(); |
| | | |
| | | /** |
| | | * Return whether this attribute contains a numeric date value or not. |
| | | * The date is a long value in miliseconds. |
| | | * @return <CODE>true</CODE> if the value is date and <CODE>false</CODE> |
| | | * otherwise. |
| | | */ |
| | | public boolean isNumericDate(); |
| | | |
| | | /** |
| | | * Return whether this attribute contains a GMT date value or not. The date |
| | | * has a format of type ServerConstants.DATE_FORMAT_GMT_TIME. |
| | | * @return <CODE>true</CODE> if the value is a GMT date and <CODE>false</CODE> |
| | | * otherwise. |
| | | */ |
| | | public boolean isGMTDate(); |
| | | |
| | | /** |
| | | * Return whether this attribute represents a value in bytes or not. |
| | | * @return <CODE>true</CODE> if the value represents a value in bytes and |
| | | * <CODE>false</CODE> otherwise. |
| | | */ |
| | | public boolean isValueInBytes(); |
| | | |
| | | /** |
| | | * Returns <CODE>true</CODE> if the average for this attribute makes sense |
| | | * and <CODE>false</CODE> otherwise. |
| | | * @return <CODE>true</CODE> if the average for this attribute makes sense |
| | | * and <CODE>false</CODE> otherwise. |
| | | */ |
| | | public boolean canHaveAverage(); |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.guitools.controlpanel.datamodel; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Comparator; |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.Set; |
| | | import java.util.TreeSet; |
| | | |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.messages.Message; |
| | | |
| | | /** |
| | | * The abstract table model used to display all the network groups. |
| | | * @param <T> the type of the objects passed externally to the table model. |
| | | * @param <P> the type of the objects used internally by the table model. |
| | | */ |
| | | public abstract class MonitoringTableModel<T, P> extends SortableTableModel |
| | | implements Comparator<P> |
| | | { |
| | | private Set<P> data = new HashSet<P>(); |
| | | private ArrayList<String[]> dataArray = new ArrayList<String[]>(); |
| | | private ArrayList<P> dataSourceArray = new ArrayList<P>(); |
| | | private boolean showAverages; |
| | | private long runningTime; |
| | | |
| | | private String[] columnNames = {}; |
| | | private Message NO_VALUE_SET = INFO_CTRL_PANEL_NO_MONITORING_VALUE.get(); |
| | | private Message NOT_IMPLEMENTED = INFO_CTRL_PANEL_NOT_IMPLEMENTED.get(); |
| | | |
| | | |
| | | /** |
| | | * The attributes to be displayed. |
| | | */ |
| | | private LinkedHashSet<MonitoringAttributes> attributes = |
| | | new LinkedHashSet<MonitoringAttributes>(); |
| | | /** |
| | | * The sort column of the table. |
| | | */ |
| | | private int sortColumn = 0; |
| | | /** |
| | | * Whether the sorting is ascending or descending. |
| | | */ |
| | | private boolean sortAscending = true; |
| | | |
| | | /** |
| | | * Indicates whether a total row must be added or not. The default behavior |
| | | * is to add it. |
| | | * @return <CODE>true</CODE> if a total row must be added and |
| | | * <CODE>false</CODE> otherwise. |
| | | */ |
| | | protected boolean addTotalRow() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * Sets the data for this table model. |
| | | * @param newData the data for this table model. |
| | | * @param runningTime the running time of the server in miliseconds. |
| | | */ |
| | | public void setData(Set<T> newData, long runningTime) |
| | | { |
| | | this.runningTime = runningTime; |
| | | Set<P> newInternalData = convertToInternalData(newData); |
| | | |
| | | // When we show the averages, the data displayed changes (even if the |
| | | // monitoring data has not). |
| | | if (!newInternalData.equals(data) || showAverages) |
| | | { |
| | | data.clear(); |
| | | data.addAll(newInternalData); |
| | | updateDataArray(); |
| | | fireTableDataChanged(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Updates the table model contents and sorts its contents depending on the |
| | | * sort options set by the user. |
| | | */ |
| | | public void forceResort() |
| | | { |
| | | updateDataArray(); |
| | | fireTableDataChanged(); |
| | | } |
| | | |
| | | /** |
| | | * Updates the table model contents, sorts its contents depending on the |
| | | * sort options set by the user and updates the column structure. |
| | | */ |
| | | public void forceDataStructureChange() |
| | | { |
| | | updateDataArray(); |
| | | fireTableStructureChanged(); |
| | | fireTableDataChanged(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public int getColumnCount() |
| | | { |
| | | return columnNames.length; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public int getRowCount() |
| | | { |
| | | return dataArray.size(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Object getValueAt(int row, int col) |
| | | { |
| | | return dataArray.get(row)[col]; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public String getColumnName(int col) { |
| | | return columnNames[col]; |
| | | } |
| | | |
| | | /** |
| | | * Returns whether the sort is ascending or descending. |
| | | * @return <CODE>true</CODE> if the sort is ascending and <CODE>false</CODE> |
| | | * otherwise. |
| | | */ |
| | | public boolean isSortAscending() |
| | | { |
| | | return sortAscending; |
| | | } |
| | | |
| | | /** |
| | | * Sets whether to sort ascending of descending. |
| | | * @param sortAscending whether to sort ascending or descending. |
| | | */ |
| | | public void setSortAscending(boolean sortAscending) |
| | | { |
| | | this.sortAscending = sortAscending; |
| | | } |
| | | |
| | | /** |
| | | * Returns the column index used to sort. |
| | | * @return the column index used to sort. |
| | | */ |
| | | public int getSortColumn() |
| | | { |
| | | return sortColumn; |
| | | } |
| | | |
| | | /** |
| | | * Sets the column index used to sort. |
| | | * @param sortColumn column index used to sort.. |
| | | */ |
| | | public void setSortColumn(int sortColumn) |
| | | { |
| | | this.sortColumn = sortColumn; |
| | | } |
| | | |
| | | /** |
| | | * Returns the attributes displayed by this table model. |
| | | * @return the attributes displayed by this table model. |
| | | */ |
| | | public Collection<MonitoringAttributes> getAttributes() |
| | | { |
| | | return attributes; |
| | | } |
| | | |
| | | /** |
| | | * Returns the header to be used for the name of the object. |
| | | * @return the header to be used for the name of the object. |
| | | */ |
| | | protected abstract Message getNameHeader(); |
| | | |
| | | /** |
| | | * Sets the operations displayed by this table model. |
| | | * @param attributes the attributes displayed by this table model. |
| | | * @param showAverages whether the averages (when makes sense) should be |
| | | * displayed or not. |
| | | */ |
| | | public void setAttributes(LinkedHashSet<MonitoringAttributes> attributes, |
| | | boolean showAverages) |
| | | { |
| | | this.showAverages = showAverages; |
| | | this.attributes.clear(); |
| | | this.attributes.addAll(attributes); |
| | | int columnCount = attributes.size() + 1; |
| | | if (showAverages) |
| | | { |
| | | for (MonitoringAttributes attr : attributes) |
| | | { |
| | | if (attr.canHaveAverage()) |
| | | { |
| | | columnCount ++; |
| | | } |
| | | } |
| | | } |
| | | columnNames = new String[columnCount]; |
| | | columnNames[0] = getHeader(getNameHeader()); |
| | | int i = 1; |
| | | for (MonitoringAttributes attribute : attributes) |
| | | { |
| | | columnNames[i] = getHeader(attribute.getMessage(), 15); |
| | | if (showAverages && attribute.canHaveAverage()) |
| | | { |
| | | i++; |
| | | columnNames[i] = getAverageHeader(attribute); |
| | | } |
| | | i++; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Updates the array data. This includes resorting it. |
| | | */ |
| | | private void updateDataArray() |
| | | { |
| | | TreeSet<P> sortedSet = new TreeSet<P>(this); |
| | | sortedSet.addAll(data); |
| | | dataArray.clear(); |
| | | dataSourceArray.clear(); |
| | | for (P ach : sortedSet) |
| | | { |
| | | String[] s = getLine(ach); |
| | | dataArray.add(s); |
| | | dataSourceArray.add(ach); |
| | | } |
| | | |
| | | // Add the total: always at the end |
| | | if (addTotalRow()) |
| | | { |
| | | String[] line = new String[columnNames.length]; |
| | | line[0] = "<html><b>"+INFO_CTRL_PANEL_TOTAL_LABEL.get().toString()+ |
| | | "</b>"; |
| | | for (int i=1; i<line.length; i++) |
| | | { |
| | | boolean valueSet = false; |
| | | boolean notImplemented = false; |
| | | long totalValue = 0; |
| | | for (int j=0; j<dataArray.size(); j++) |
| | | { |
| | | String[] l = dataArray.get(j); |
| | | String value = l[i]; |
| | | try |
| | | { |
| | | long v = Long.parseLong(value); |
| | | totalValue += v; |
| | | valueSet = true; |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | notImplemented = NOT_IMPLEMENTED.toString().equals(value); |
| | | } |
| | | } |
| | | if (notImplemented) |
| | | { |
| | | line[i] = NOT_IMPLEMENTED.toString(); |
| | | } |
| | | else if (valueSet) |
| | | { |
| | | line[i] = String.valueOf(totalValue); |
| | | } |
| | | else |
| | | { |
| | | line[i] = NO_VALUE_SET.toString(); |
| | | } |
| | | } |
| | | dataArray.add(line); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected String[] getColumnNames() |
| | | { |
| | | return columnNames; |
| | | } |
| | | |
| | | /** |
| | | * Converts the provided data into internal data to be used by the table |
| | | * model. |
| | | * @param o the set of objects to convert. |
| | | * @return the set of objects to be used by the table model. |
| | | */ |
| | | protected abstract Set<P> convertToInternalData(Set<T> o); |
| | | |
| | | /** |
| | | * Returns the label to be used for the provided internal object. |
| | | * @param o the internal object. |
| | | * @return the label to be used for the provided internal object. |
| | | */ |
| | | protected abstract String getName(P o); |
| | | |
| | | /** |
| | | * Returns the monitoring entry associated with the provided object. |
| | | * @param o the internal object. |
| | | * @return the monitoring entry associated with the provided object. Returns |
| | | * <CODE>null</CODE> if there is no monitoring entry associated. |
| | | */ |
| | | protected abstract CustomSearchResult getMonitoringEntry(P o); |
| | | |
| | | private String[] getLine(P o) |
| | | { |
| | | String[] line = new String[columnNames.length]; |
| | | line[0] = getName(o); |
| | | int i = 1; |
| | | CustomSearchResult monitoringEntry = getMonitoringEntry(o); |
| | | for (MonitoringAttributes attribute : attributes) |
| | | { |
| | | line[i] = Utilities.getMonitoringValue( |
| | | attribute, monitoringEntry); |
| | | if (showAverages && attribute.canHaveAverage()) |
| | | { |
| | | i++; |
| | | try |
| | | { |
| | | if (runningTime > 0) |
| | | { |
| | | long v = Long.parseLong(line[i - 1]); |
| | | long average = (1000 * v) / runningTime; |
| | | String s = String.valueOf(average); |
| | | int index = s.indexOf("."); |
| | | // Show a maximum of two decimals. |
| | | if ((index != -1) && ((index + 3) < s.length())) |
| | | { |
| | | s = s.substring(0, index + 3); |
| | | } |
| | | line[i] = s; |
| | | } |
| | | else |
| | | { |
| | | line[i] = NO_VALUE_SET.toString(); |
| | | } |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | line[i] = NO_VALUE_SET.toString(); |
| | | } |
| | | } |
| | | i++; |
| | | } |
| | | return line; |
| | | } |
| | | |
| | | /** |
| | | * Returns the String to be used as header on the table to display the average |
| | | * for a given monitoring attribute. |
| | | * @param attr the monitoring attribute. |
| | | * @return the String to be used as header on the table to display the average |
| | | * for a given monitoring attribute. |
| | | */ |
| | | private String getAverageHeader(MonitoringAttributes attr) |
| | | { |
| | | return getHeader(INFO_CTRL_PANEL_AVERAGE_HEADER.get( |
| | | attr.getMessage().toString()), 15); |
| | | } |
| | | |
| | | /** |
| | | * Returns the first value for a given attribute in the provided entry. |
| | | * @param sr the entry. |
| | | * @param attrName the attribute name. |
| | | * @return the first value for a given attribute in the provided entry. |
| | | */ |
| | | protected Object getFirstMonitoringValue(CustomSearchResult sr, |
| | | String attrName) |
| | | { |
| | | return Utilities.getFirstMonitoringValue(sr, attrName); |
| | | } |
| | | |
| | | /** |
| | | * Returns a list of integer with all the values of two monitoring entries |
| | | * compared. |
| | | * @param monitor1 the first monitoring entry. |
| | | * @param monitor2 the second monitoring entry. |
| | | * @return a list of integer with all the values of two monitoring entries |
| | | * compared. |
| | | */ |
| | | protected ArrayList<Integer> getMonitoringPossibleResults( |
| | | CustomSearchResult monitor1, CustomSearchResult monitor2) |
| | | { |
| | | ArrayList<Integer> possibleResults = new ArrayList<Integer>(); |
| | | for (MonitoringAttributes operation : getAttributes()) |
| | | { |
| | | int possibleResult; |
| | | if (monitor1 == null) |
| | | { |
| | | if (monitor2 == null) |
| | | { |
| | | possibleResult = 0; |
| | | } |
| | | else |
| | | { |
| | | possibleResult = -1; |
| | | } |
| | | } |
| | | else if (monitor2 == null) |
| | | { |
| | | possibleResult = 1; |
| | | } |
| | | else |
| | | { |
| | | Object v1 = null; |
| | | Object v2 = null; |
| | | |
| | | for (String attrName : monitor1.getAttributeNames()) |
| | | { |
| | | if (operation.getAttributeName().equalsIgnoreCase(attrName)) |
| | | { |
| | | v1 = getFirstMonitoringValue(monitor1, attrName); |
| | | break; |
| | | } |
| | | } |
| | | for (String attrName : monitor2.getAttributeNames()) |
| | | { |
| | | if (operation.getAttributeName().equalsIgnoreCase(attrName)) |
| | | { |
| | | v2 = getFirstMonitoringValue(monitor2, attrName); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (v1 == null) |
| | | { |
| | | if (v2 == null) |
| | | { |
| | | possibleResult = 0; |
| | | } |
| | | else |
| | | { |
| | | possibleResult = -1; |
| | | } |
| | | } |
| | | else if (v2 == null) |
| | | { |
| | | possibleResult = 1; |
| | | } |
| | | else |
| | | { |
| | | if (v1 instanceof Number) |
| | | { |
| | | if (v2 instanceof Number) |
| | | { |
| | | if ((v1 instanceof Double) || (v2 instanceof Double)) |
| | | { |
| | | double n1 = ((Number)v1).doubleValue(); |
| | | double n2 = ((Number)v2).doubleValue(); |
| | | if (n1 > n2) |
| | | { |
| | | possibleResult = 1; |
| | | } |
| | | else if (n1 < n2) |
| | | { |
| | | possibleResult = -1; |
| | | } |
| | | else |
| | | { |
| | | possibleResult = 0; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | long n1 = ((Number)v1).longValue(); |
| | | long n2 = ((Number)v2).longValue(); |
| | | if (n1 > n2) |
| | | { |
| | | possibleResult = 1; |
| | | } |
| | | else if (n1 < n2) |
| | | { |
| | | possibleResult = -1; |
| | | } |
| | | else |
| | | { |
| | | possibleResult = 0; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | possibleResult = 1; |
| | | } |
| | | } |
| | | else if (v2 instanceof Number) |
| | | { |
| | | possibleResult = -1; |
| | | } |
| | | else |
| | | { |
| | | possibleResult = v1.toString().compareTo(v2.toString()); |
| | | } |
| | | } |
| | | } |
| | | possibleResults.add(possibleResult); |
| | | } |
| | | return possibleResults; |
| | | } |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.datamodel; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | import org.opends.guitools.controlpanel.util.ConfigFromDirContext; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | |
| | | import org.opends.server.types.AttributeType; |
| | |
| | | private boolean isSchemaEnabled; |
| | | private Schema schema; |
| | | |
| | | private CustomSearchResult rootMonitor; |
| | | |
| | | private CustomSearchResult jvmMemoryUsage; |
| | | |
| | | private CustomSearchResult systemInformation; |
| | | |
| | | private CustomSearchResult entryCaches; |
| | | |
| | | private CustomSearchResult workQueue; |
| | | |
| | | private long runningTime = -1; |
| | | |
| | | private boolean isAuthenticated; |
| | | |
| | | private static String hostName = "locahost"; |
| | |
| | | public void setAdminConnector(ConnectionHandlerDescriptor adminConnector) |
| | | { |
| | | this.adminConnector = adminConnector; |
| | | }/** |
| | | * Sets the monitoring entry for the entry caches. |
| | | * @param entryCaches the monitoring entry for the entry caches. |
| | | */ |
| | | public void setEntryCachesMonitor(CustomSearchResult entryCaches) |
| | | { |
| | | this.entryCaches = entryCaches; |
| | | } |
| | | |
| | | /** |
| | | * Sets the monitoring entry for the JVM memory usage. |
| | | * @param jvmMemoryUsage the monitoring entry for the JVM memory usage. |
| | | */ |
| | | public void setJvmMemoryUsageMonitor(CustomSearchResult jvmMemoryUsage) |
| | | { |
| | | this.jvmMemoryUsage = jvmMemoryUsage; |
| | | } |
| | | |
| | | /** |
| | | * Sets the root entry of the monitoring tree. |
| | | * @param rootMonitor the root entry of the monitoring tree. |
| | | */ |
| | | public void setRootMonitor(CustomSearchResult rootMonitor) |
| | | { |
| | | this.rootMonitor = rootMonitor; |
| | | if (rootMonitor != null) |
| | | { |
| | | try |
| | | { |
| | | String start = (String)Utilities.getFirstMonitoringValue( |
| | | rootMonitor, |
| | | BasicMonitoringAttributes.START_DATE.getAttributeName()); |
| | | String current = (String) |
| | | Utilities.getFirstMonitoringValue(rootMonitor, |
| | | BasicMonitoringAttributes.CURRENT_DATE.getAttributeName()); |
| | | Date startTime = ConfigFromDirContext.utcParser.parse(start); |
| | | Date currentTime = ConfigFromDirContext.utcParser.parse(current); |
| | | runningTime = currentTime.getTime() - startTime.getTime(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | runningTime = -1; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | runningTime = -1; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns the running time of the server in milliseconds. Returns -1 if |
| | | * no running time could be found. |
| | | * @return the running time of the server in milliseconds. |
| | | */ |
| | | public long getRunningTime() |
| | | { |
| | | return runningTime; |
| | | } |
| | | |
| | | /** |
| | | * Sets the monitoring entry for the system information. |
| | | * @param systemInformation entry for the system information. |
| | | */ |
| | | public void setSystemInformationMonitor(CustomSearchResult systemInformation) |
| | | { |
| | | this.systemInformation = systemInformation; |
| | | } |
| | | |
| | | /** |
| | | * Sets the monitoring entry of the work queue. |
| | | * @param workQueue entry of the work queue. |
| | | */ |
| | | public void setWorkQueueMonitor(CustomSearchResult workQueue) |
| | | { |
| | | this.workQueue = workQueue; |
| | | } |
| | | |
| | | /** |
| | | * Returns the monitoring entry for the entry caches. |
| | | * @return the monitoring entry for the entry caches. |
| | | */ |
| | | public CustomSearchResult getEntryCachesMonitor() |
| | | { |
| | | return entryCaches; |
| | | } |
| | | |
| | | /** |
| | | * Returns the monitoring entry for the JVM memory usage. |
| | | * @return the monitoring entry for the JVM memory usage. |
| | | */ |
| | | public CustomSearchResult getJvmMemoryUsageMonitor() |
| | | { |
| | | return jvmMemoryUsage; |
| | | } |
| | | |
| | | /** |
| | | * Returns the root entry of the monitoring tree. |
| | | * @return the root entry of the monitoring tree. |
| | | */ |
| | | public CustomSearchResult getRootMonitor() |
| | | { |
| | | return rootMonitor; |
| | | } |
| | | |
| | | /** |
| | | * Returns the monitoring entry for the system information. |
| | | * @return the monitoring entry for the system information. |
| | | */ |
| | | public CustomSearchResult getSystemInformationMonitor() |
| | | { |
| | | return systemInformation; |
| | | } |
| | | |
| | | /** |
| | | * Returns the monitoring entry for the work queue. |
| | | * @return the monitoring entry for the work queue. |
| | | */ |
| | | public CustomSearchResult getWorkQueueMonitor() |
| | | { |
| | | return workQueue; |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.Dimension; |
| | | import java.awt.GridBagConstraints; |
| | | import java.awt.GridBagLayout; |
| | | import java.awt.Insets; |
| | | import java.util.HashMap; |
| | | |
| | | import javax.swing.ImageIcon; |
| | | import javax.swing.JPanel; |
| | | import javax.swing.JScrollPane; |
| | | import javax.swing.JSplitPane; |
| | | import javax.swing.JTree; |
| | | import javax.swing.SwingUtilities; |
| | | import javax.swing.border.EmptyBorder; |
| | | import javax.swing.event.TreeSelectionEvent; |
| | | import javax.swing.event.TreeSelectionListener; |
| | | import javax.swing.tree.DefaultMutableTreeNode; |
| | | import javax.swing.tree.DefaultTreeModel; |
| | | import javax.swing.tree.TreePath; |
| | | |
| | | import org.opends.guitools.controlpanel.browser.IconPool; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | | import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.ui.components.TreePanel; |
| | | import org.opends.guitools.controlpanel.ui.nodes.GeneralMonitoringTreeNode; |
| | | import org.opends.guitools.controlpanel.ui.renderer.TreeCellRenderer; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.guitools.controlpanel.util.ViewPositions; |
| | | import org.opends.messages.Message; |
| | | import org.opends.messages.MessageBuilder; |
| | | |
| | | /** |
| | | * The pane that is displayed when the user clicks on 'General Monitoring'. |
| | | * |
| | | */ |
| | | public class BrowseGeneralMonitoringPanel extends StatusGenericPanel |
| | | { |
| | | private static final long serialVersionUID = 6462914563746678830L; |
| | | |
| | | /** |
| | | * The panel containing the tree. |
| | | */ |
| | | private TreePanel treePane; |
| | | |
| | | private JScrollPane treeScroll; |
| | | |
| | | private ServerDescriptor lastServer; |
| | | |
| | | private String lastServerName; |
| | | |
| | | private boolean ignoreSelectionEvents; |
| | | |
| | | private Message NO_ELEMENT_SELECTED = |
| | | INFO_CTRL_PANEL_GENERAL_MONITORING_NO_ITEM_SELECTED.get(); |
| | | private Message MULTIPLE_ITEMS_SELECTED = |
| | | INFO_CTRL_PANEL_MULTIPLE_ITEMS_SELECTED.get(); |
| | | |
| | | /** |
| | | * The enumeration used to define the different static nodes of the tree. |
| | | * |
| | | */ |
| | | protected enum NodeType |
| | | { |
| | | /** |
| | | * Root node. |
| | | */ |
| | | ROOT, |
| | | /** |
| | | * System information node. |
| | | */ |
| | | SYSTEM_INFORMATION, |
| | | /** |
| | | * Java information node. |
| | | */ |
| | | JAVA_INFORMATION, |
| | | /** |
| | | * Work queue node. |
| | | */ |
| | | WORK_QUEUE, |
| | | /** |
| | | * Entry caches node. |
| | | */ |
| | | ENTRY_CACHES, |
| | | /** |
| | | * Database environment node. |
| | | */ |
| | | DB_ENVIRONMENT |
| | | } |
| | | |
| | | /** |
| | | * The panel displaying the informations about the selected node. |
| | | */ |
| | | protected GeneralMonitoringRightPanel entryPane; |
| | | |
| | | /** |
| | | * Default constructor. |
| | | * |
| | | */ |
| | | public BrowseGeneralMonitoringPanel() |
| | | { |
| | | super(); |
| | | createLayout(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean requiresBorder() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean requiresScroll() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean callConfigurationChangedInBackground() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void toBeDisplayed(boolean visible) |
| | | { |
| | | ((GenericDialog)Utilities.getParentDialog(this)).getRootPane(). |
| | | setDefaultButton(null); |
| | | } |
| | | |
| | | /** |
| | | * Creates the layout of the panel (but the contents are not populated here). |
| | | */ |
| | | private void createLayout() |
| | | { |
| | | setBackground(ColorAndFontConstants.greyBackground); |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | gbc.anchor = GridBagConstraints.WEST; |
| | | gbc.gridx = 0; |
| | | gbc.gridy = 0; |
| | | gbc.gridwidth = 1; |
| | | gbc.weightx = 1.0; |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | addErrorPane(gbc); |
| | | |
| | | gbc.insets = new Insets(10, 0, 0, 0); |
| | | gbc.gridx = 0; |
| | | gbc.gridy ++; |
| | | gbc.weightx = 1.0; |
| | | gbc.weighty = 1.0; |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | gbc.gridwidth = 7; |
| | | add(createSplitPane(), gbc); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Message getTitle() |
| | | { |
| | | return INFO_CTRL_PANEL_GENERAL_MONITORING_TITLE.get(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Component getPreferredFocusComponent() |
| | | { |
| | | return treePane; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void okClicked() |
| | | { |
| | | // No ok button |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public GenericDialog.ButtonType getButtonType() |
| | | { |
| | | return GenericDialog.ButtonType.CLOSE; |
| | | } |
| | | |
| | | /** |
| | | * Creates the browser right panel. |
| | | * @return the created browser right panel. |
| | | */ |
| | | private GeneralMonitoringRightPanel createBrowserRightPanel() |
| | | { |
| | | return new GeneralMonitoringRightPanel(); |
| | | } |
| | | |
| | | private Component createSplitPane() |
| | | { |
| | | treePane = new TreePanel(); |
| | | |
| | | entryPane = createBrowserRightPanel(); |
| | | |
| | | JPanel p = new JPanel(new GridBagLayout()); |
| | | p.setBackground(ColorAndFontConstants.background); |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | gbc.gridx = 0; |
| | | gbc.gridy = 0; |
| | | gbc.gridwidth = 1; |
| | | gbc.anchor = GridBagConstraints.NORTHWEST; |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | gbc.weightx = 1.0; |
| | | gbc.weighty = 1.0; |
| | | Utilities.setBorder(treePane, new EmptyBorder(10, 0, 10, 0)); |
| | | p.add(treePane, gbc); |
| | | treeScroll = Utilities.createScrollPane(p); |
| | | |
| | | treePane.getTree().addTreeSelectionListener(new TreeSelectionListener() |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void valueChanged(TreeSelectionEvent ev) |
| | | { |
| | | if (!ignoreSelectionEvents) |
| | | { |
| | | ignoreSelectionEvents = true; |
| | | updateEntryPane(); |
| | | ignoreSelectionEvents = false; |
| | | } |
| | | } |
| | | }); |
| | | JTree tree = treePane.getTree(); |
| | | repopulateTree(tree, true); |
| | | tree.setRootVisible(true); |
| | | tree.setVisibleRowCount(20); |
| | | tree.expandPath(new TreePath(getRoot(tree))); |
| | | tree.setCellRenderer(new GeneralMonitoringTreeCellRenderer()); |
| | | treeScroll.setPreferredSize( |
| | | new Dimension(treeScroll.getPreferredSize().width + 30, |
| | | 3 * treeScroll.getPreferredSize().height)); |
| | | entryPane.displayMessage(NO_ELEMENT_SELECTED); |
| | | entryPane.setBorder(getRightPanelBorder()); |
| | | entryPane.setPreferredSize( |
| | | new Dimension(treeScroll.getPreferredSize().width * 2, |
| | | treeScroll.getPreferredSize().height)); |
| | | JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); |
| | | pane.setOpaque(true); //content panes must be opaque |
| | | pane.setLeftComponent(treeScroll); |
| | | pane.setRightComponent(entryPane); |
| | | pane.setResizeWeight(0.0); |
| | | pane.setDividerLocation(treeScroll.getPreferredSize().width); |
| | | return pane; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void setInfo(ControlPanelInfo info) |
| | | { |
| | | super.setInfo(info); |
| | | treePane.setInfo(info); |
| | | entryPane.setInfo(info); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void configurationChanged(ConfigurationChangeEvent ev) |
| | | { |
| | | ServerDescriptor server = ev.getNewDescriptor(); |
| | | if (serverChanged(server)) |
| | | { |
| | | final boolean firstTimeCalled = lastServer == null; |
| | | lastServer = server; |
| | | |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | public void run() |
| | | { |
| | | String serverName = getServerName(lastServer); |
| | | // Repopulate the tree to display a root node with server information |
| | | if (!serverName.equals(lastServerName)) |
| | | { |
| | | repopulateTree(treePane.getTree(), false); |
| | | lastServerName = serverName; |
| | | } |
| | | if (firstTimeCalled) |
| | | { |
| | | // Select the root |
| | | treePane.getTree().setSelectionInterval(0, 0); |
| | | } |
| | | else |
| | | { |
| | | // Reselect |
| | | updateEntryPane(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | lastServer = server; |
| | | } |
| | | |
| | | boolean displayErrorPane = false; |
| | | Message errorTitle = Message.EMPTY; |
| | | Message errorDetails = Message.EMPTY; |
| | | ServerDescriptor.ServerStatus status = server.getStatus(); |
| | | if (status == ServerDescriptor.ServerStatus.STARTED) |
| | | { |
| | | if (!server.isAuthenticated()) |
| | | { |
| | | MessageBuilder mb = new MessageBuilder(); |
| | | mb.append( |
| | | INFO_CTRL_PANEL_AUTH_REQUIRED_TO_BROWSE_MONITORING_SUMMARY. |
| | | get()); |
| | | mb.append("<br><br>"+getAuthenticateHTML()); |
| | | errorDetails = mb.toMessage(); |
| | | errorTitle = INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_SUMMARY.get(); |
| | | |
| | | displayErrorPane = true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | errorTitle = INFO_CTRL_PANEL_SERVER_NOT_RUNNING_SUMMARY.get(); |
| | | MessageBuilder mb = new MessageBuilder(); |
| | | mb.append( |
| | | INFO_CTRL_PANEL_SERVER_MUST_RUN_TO_BROWSE_MONITORING_SUMMARY. |
| | | get()); |
| | | mb.append("<br><br>"); |
| | | mb.append(getStartServerHTML()); |
| | | errorDetails = mb.toMessage(); |
| | | displayErrorPane = true; |
| | | } |
| | | final boolean fDisplayErrorPane = displayErrorPane; |
| | | final Message fErrorTitle = errorTitle; |
| | | final Message fErrorDetails = errorDetails; |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void run() |
| | | { |
| | | errorPane.setVisible(fDisplayErrorPane); |
| | | if (fDisplayErrorPane) |
| | | { |
| | | updateErrorPane(errorPane, fErrorTitle, |
| | | ColorAndFontConstants.errorTitleFont, fErrorDetails, |
| | | ColorAndFontConstants.defaultFont); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * Populates the tree. Should be called only once since the tree in this |
| | | * panel is static. |
| | | * @param tree the tree to be repopulated. |
| | | * @param forceScroll whether the scroll must be reset or not. |
| | | */ |
| | | private void repopulateTree(JTree tree, boolean forceScroll) |
| | | { |
| | | ignoreSelectionEvents = true; |
| | | |
| | | ViewPositions pos = Utilities.getViewPositions(treeScroll); |
| | | |
| | | ServerDescriptor server = null; |
| | | if (getInfo() != null) |
| | | { |
| | | server = getInfo().getServerDescriptor(); |
| | | } |
| | | GeneralMonitoringTreeNode root; |
| | | if (server == null) |
| | | { |
| | | root = |
| | | new GeneralMonitoringTreeNode( |
| | | INFO_CTRL_PANEL_GENERAL_MONITORING_ROOT.get().toString(), |
| | | NodeType.ROOT, |
| | | true); |
| | | } |
| | | else |
| | | { |
| | | root = |
| | | new GeneralMonitoringTreeNode( |
| | | getServerName(server), |
| | | NodeType.ROOT, |
| | | true); |
| | | } |
| | | |
| | | Message[] messages = getNodeMessages(); |
| | | NodeType[] identifiers = getNodeTypes(); |
| | | for (int i=0; i < messages.length; i++) |
| | | { |
| | | root.add(new GeneralMonitoringTreeNode(messages[i].toString(), |
| | | identifiers[i], false)); |
| | | } |
| | | |
| | | DefaultTreeModel model = new DefaultTreeModel(root); |
| | | tree.setModel(model); |
| | | |
| | | Utilities.updateViewPositions(pos); |
| | | ignoreSelectionEvents = false; |
| | | } |
| | | |
| | | /** |
| | | * Updates the right entry panel. |
| | | * |
| | | */ |
| | | private void updateEntryPane() |
| | | { |
| | | ViewPositions pos = Utilities.getViewPositions(entryPane); |
| | | boolean canDisplayMonitorInformation = true; |
| | | if (getInfo() == null) |
| | | { |
| | | return; |
| | | } |
| | | ServerDescriptor server = getInfo().getServerDescriptor(); |
| | | ServerDescriptor.ServerStatus status = server.getStatus(); |
| | | if (status == ServerDescriptor.ServerStatus.STARTED) |
| | | { |
| | | if (!server.isAuthenticated()) |
| | | { |
| | | canDisplayMonitorInformation = false; |
| | | entryPane.displayMessage( |
| | | INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_SUMMARY.get()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | canDisplayMonitorInformation = false; |
| | | entryPane.displayMessage( |
| | | INFO_CTRL_PANEL_SERVER_NOT_RUNNING_SUMMARY.get()); |
| | | } |
| | | |
| | | if (canDisplayMonitorInformation) |
| | | { |
| | | TreePath[] paths = treePane.getTree().getSelectionPaths(); |
| | | TreePath path = null; |
| | | if ((paths != null) && (paths.length == 1)) |
| | | { |
| | | path = paths[0]; |
| | | } |
| | | if (path != null) |
| | | { |
| | | GeneralMonitoringTreeNode node = |
| | | (GeneralMonitoringTreeNode)path.getLastPathComponent(); |
| | | NodeType type = (NodeType)node.getIdentifier(); |
| | | switch (type) |
| | | { |
| | | case ROOT: |
| | | entryPane.updateRoot(); |
| | | break; |
| | | case SYSTEM_INFORMATION: |
| | | entryPane.updateSystemInformation(); |
| | | break; |
| | | case WORK_QUEUE: |
| | | entryPane.updateWorkQueue(); |
| | | break; |
| | | case ENTRY_CACHES: |
| | | entryPane.updateEntryCaches(); |
| | | break; |
| | | case DB_ENVIRONMENT: |
| | | entryPane.updateDBEnvironment(); |
| | | break; |
| | | case JAVA_INFORMATION: |
| | | entryPane.updateJavaInformation(); |
| | | break; |
| | | default: |
| | | throw new IllegalStateException("Unknown node type: "+type); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if ((paths != null) && (paths.length > 1)) |
| | | { |
| | | entryPane.displayMessage(MULTIPLE_ITEMS_SELECTED); |
| | | } |
| | | else |
| | | { |
| | | entryPane.displayMessage(NO_ELEMENT_SELECTED); |
| | | } |
| | | } |
| | | } |
| | | Utilities.updateViewPositions(pos); |
| | | } |
| | | |
| | | private DefaultMutableTreeNode getRoot(JTree tree) |
| | | { |
| | | return (DefaultMutableTreeNode)tree.getModel().getRoot(); |
| | | } |
| | | |
| | | private boolean serverChanged(ServerDescriptor desc) |
| | | { |
| | | boolean changed = false; |
| | | if (lastServer != null) |
| | | { |
| | | // Just compare the elements interesting for this panel |
| | | changed = |
| | | !desc.getBackends().equals(lastServer.getBackends()); |
| | | if (!changed) |
| | | { |
| | | CustomSearchResult[] monitor1 = |
| | | { |
| | | lastServer.getEntryCachesMonitor(), |
| | | lastServer.getJvmMemoryUsageMonitor(), |
| | | lastServer.getRootMonitor(), |
| | | lastServer.getSystemInformationMonitor(), |
| | | lastServer.getWorkQueueMonitor() |
| | | }; |
| | | CustomSearchResult[] monitor2 = |
| | | { |
| | | desc.getEntryCachesMonitor(), |
| | | desc.getJvmMemoryUsageMonitor(), |
| | | desc.getRootMonitor(), |
| | | desc.getSystemInformationMonitor(), |
| | | desc.getWorkQueueMonitor() |
| | | }; |
| | | for (int i=0; i<monitor1.length && !changed; i++) |
| | | { |
| | | if (monitor1[i] == null) |
| | | { |
| | | changed = monitor2[i] != null; |
| | | } |
| | | else |
| | | { |
| | | changed = !monitor1[i].equals(monitor2[i]); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | changed = true; |
| | | } |
| | | return changed; |
| | | } |
| | | |
| | | private HashMap<Object, ImageIcon> hmImages = |
| | | new HashMap<Object, ImageIcon>(); |
| | | { |
| | | NodeType[] identifiers = { |
| | | NodeType.ROOT, |
| | | NodeType.SYSTEM_INFORMATION, |
| | | NodeType.JAVA_INFORMATION, |
| | | NodeType.WORK_QUEUE, |
| | | NodeType.ENTRY_CACHES, |
| | | NodeType.DB_ENVIRONMENT |
| | | }; |
| | | Message[] ocPaths = { |
| | | INFO_CTRL_PANEL_GENERAL_MONITORING_ROOT_TREE_NODE.get(), |
| | | INFO_CTRL_PANEL_SYSTEM_INFORMATION_TREE_NODE.get(), |
| | | INFO_CTRL_PANEL_JVM_MEMORY_USAGE_TREE_NODE.get(), |
| | | INFO_CTRL_PANEL_WORK_QUEUE_TREE_NODE.get(), |
| | | INFO_CTRL_PANEL_ENTRY_CACHES_TREE_NODE.get(), |
| | | INFO_CTRL_PANEL_DB_ENVIRONMENT_TREE_NODE.get() |
| | | }; |
| | | for (int i=0; i<identifiers.length; i++) |
| | | { |
| | | hmImages.put(identifiers[i], |
| | | Utilities.createImageIcon(IconPool.IMAGE_PATH+"/"+ocPaths[i], |
| | | getClass().getClassLoader())); |
| | | } |
| | | }; |
| | | |
| | | private String getServerName(ServerDescriptor server) |
| | | { |
| | | String serverName = server.getHostname()+":"+ |
| | | server.getAdminConnector().getPort(); |
| | | return serverName; |
| | | } |
| | | |
| | | /** |
| | | * Specific class used to render the nodes in the tree. It uses specific |
| | | * icons for the nodes. |
| | | * |
| | | */ |
| | | protected class GeneralMonitoringTreeCellRenderer extends TreeCellRenderer |
| | | { |
| | | private static final long serialVersionUID = -3390566664259441766L; |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Component getTreeCellRendererComponent(JTree tree, Object value, |
| | | boolean isSelected, boolean isExpanded, boolean isLeaf, int row, |
| | | boolean hasFocus) |
| | | { |
| | | super.getTreeCellRendererComponent(tree, value, isSelected, isExpanded, |
| | | isLeaf, row, hasFocus); |
| | | setIcon(getIcon(value)); |
| | | return this; |
| | | } |
| | | |
| | | private ImageIcon getIcon(Object value) |
| | | { |
| | | ImageIcon icon = null; |
| | | if (value instanceof GeneralMonitoringTreeNode) |
| | | { |
| | | icon = hmImages.get( |
| | | ((GeneralMonitoringTreeNode)value).getIdentifier()); |
| | | } |
| | | else |
| | | { |
| | | throw new IllegalStateException("Unexpected tree node: "+value); |
| | | } |
| | | return icon; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns the labels of the nodes to be displayed. |
| | | * @return the labels of the nodes to be displayed. |
| | | */ |
| | | protected Message[] getNodeMessages() |
| | | { |
| | | return new Message[] { |
| | | INFO_CTRL_PANEL_SYSTEM_INFORMATION.get(), |
| | | INFO_CTRL_PANEL_JAVA_INFORMATION.get(), |
| | | INFO_CTRL_PANEL_WORK_QUEUE.get(), |
| | | INFO_CTRL_PANEL_ENTRY_CACHES.get(), |
| | | INFO_CTRL_PANEL_DB_ENVIRONMENT.get() |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * Returns the node types to be displayed. |
| | | * @return the node types to be displayed. |
| | | */ |
| | | protected NodeType[] getNodeTypes() |
| | | { |
| | | return new NodeType[] { |
| | | NodeType.SYSTEM_INFORMATION, |
| | | NodeType.JAVA_INFORMATION, |
| | | NodeType.WORK_QUEUE, |
| | | NodeType.ENTRY_CACHES, |
| | | NodeType.DB_ENVIRONMENT |
| | | }; |
| | | } |
| | | } |
| | | |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | | import java.awt.GridBagLayout; |
| | | import java.awt.Insets; |
| | | import java.awt.event.ActionEvent; |
| | | import java.awt.event.ActionListener; |
| | | import java.awt.event.ItemEvent; |
| | | import java.awt.event.ItemListener; |
| | | import java.awt.event.KeyEvent; |
| | | import java.net.InetAddress; |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.Set; |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | | |
| | | import javax.swing.BorderFactory; |
| | | import javax.swing.Box; |
| | | import javax.swing.DefaultComboBoxModel; |
| | | import javax.swing.JCheckBoxMenuItem; |
| | | import javax.swing.JComboBox; |
| | | import javax.swing.JLabel; |
| | | import javax.swing.JList; |
| | | import javax.swing.JMenu; |
| | | import javax.swing.JMenuBar; |
| | | import javax.swing.JMenuItem; |
| | | import javax.swing.JPanel; |
| | | import javax.swing.JScrollPane; |
| | | import javax.swing.JTable; |
| | | import javax.swing.SwingUtilities; |
| | | import javax.swing.table.DefaultTableCellRenderer; |
| | | |
| | | import org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes; |
| | | import org.opends.guitools.controlpanel.datamodel.CategorizedComboBoxElement; |
| | | import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel. |
| | | ConnectionHandlersMonitoringTableModel; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | | import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; |
| | | import org.opends.guitools.controlpanel.datamodel.MonitoringAttributes; |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor. |
| | | Protocol; |
| | | import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor. |
| | | State; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.ui.StatusGenericPanel. |
| | | IgnoreItemListener; |
| | | import org.opends.guitools.controlpanel.ui.renderer.CustomListCellRenderer; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.guitools.controlpanel.util.ViewPositions; |
| | | import org.opends.messages.Message; |
| | | import org.opends.messages.MessageBuilder; |
| | | |
| | | /** |
| | | * Class that displays the monitoring information of connection handlers. |
| | | * |
| | | */ |
| | | public class ConnectionHandlerMonitoringPanel extends StatusGenericPanel |
| | | { |
| | | private static final long serialVersionUID = -6462932160985559830L; |
| | | |
| | | private MonitoringAttributesViewPanel<MonitoringAttributes> |
| | | operationViewPanel; |
| | | private GenericDialog operationViewDlg; |
| | | |
| | | private JComboBox connectionHandlers; |
| | | |
| | | private JTable connectionHandlersTable; |
| | | private JScrollPane connectionHandlersScroll; |
| | | private ConnectionHandlersMonitoringTableModel connectionHandlersTableModel; |
| | | |
| | | private JLabel lNoConnectionHandlers = Utilities.createPrimaryLabel( |
| | | INFO_CTRL_PANEL_NO_CONNECTION_HANDLER_FOUND.get()); |
| | | |
| | | private boolean firstRealDataSet = false; |
| | | |
| | | private JCheckBoxMenuItem showAveragesMenu; |
| | | |
| | | private ConnectionHandlerMonitoringMenuBar menuBar; |
| | | |
| | | private LinkedHashSet<MonitoringAttributes> chOperations = |
| | | new LinkedHashSet<MonitoringAttributes>(); |
| | | { |
| | | chOperations.add(BasicMonitoringAttributes.ADD_REQUESTS); |
| | | chOperations.add(BasicMonitoringAttributes.BIND_REQUESTS); |
| | | chOperations.add(BasicMonitoringAttributes.DELETE_REQUESTS); |
| | | chOperations.add(BasicMonitoringAttributes.MOD_REQUESTS); |
| | | chOperations.add(BasicMonitoringAttributes.MOD_DN_REQUESTS); |
| | | chOperations.add(BasicMonitoringAttributes.SEARCH_REQUESTS); |
| | | } |
| | | private LinkedHashSet<MonitoringAttributes> allowedChOperations = |
| | | new LinkedHashSet<MonitoringAttributes>(); |
| | | { |
| | | allowedChOperations.addAll(chOperations); |
| | | allowedChOperations.add(BasicMonitoringAttributes.ADD_RESPONSES); |
| | | allowedChOperations.add(BasicMonitoringAttributes.BIND_RESPONSES); |
| | | allowedChOperations.add(BasicMonitoringAttributes.COMPARE_RESPONSES); |
| | | allowedChOperations.add(BasicMonitoringAttributes.DELETE_RESPONSES); |
| | | allowedChOperations.add(BasicMonitoringAttributes.EXTENDED_REQUESTS); |
| | | allowedChOperations.add(BasicMonitoringAttributes.EXTENDED_RESPONSES); |
| | | allowedChOperations.add(BasicMonitoringAttributes.MOD_DN_RESPONSES); |
| | | allowedChOperations.add(BasicMonitoringAttributes.MOD_RESPONSES); |
| | | allowedChOperations.add(BasicMonitoringAttributes.SEARCH_DONE); |
| | | allowedChOperations.add(BasicMonitoringAttributes.UNBIND_REQUESTS); |
| | | } |
| | | |
| | | private Message ALL_CONNECTION_HANDLERS = |
| | | INFO_CTRL_PANEL_ALL_CONNECTION_HANDLERS.get(); |
| | | |
| | | /** |
| | | * Default constructor. |
| | | * |
| | | */ |
| | | public ConnectionHandlerMonitoringPanel() |
| | | { |
| | | super(); |
| | | createLayout(); |
| | | } |
| | | |
| | | /** |
| | | * Creates the layout of the panel (but the contents are not populated here). |
| | | */ |
| | | private void createLayout() |
| | | { |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | gbc.gridx = 0; |
| | | gbc.gridy = 0; |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | gbc.gridwidth = 1; |
| | | gbc.weightx = 1.0; |
| | | gbc.anchor = GridBagConstraints.NORTHWEST; |
| | | addErrorPane(gbc); |
| | | gbc.weighty = 1.0; |
| | | JPanel viewOptions = new JPanel(new GridBagLayout()); |
| | | viewOptions.setBackground(ColorAndFontConstants.greyBackground); |
| | | viewOptions.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, |
| | | ColorAndFontConstants.defaultBorderColor)); |
| | | gbc.gridwidth = 1; |
| | | JLabel l = Utilities.createPrimaryLabel( |
| | | INFO_CTRL_PANEL_CONNECTION_HANDLERS_LABEL.get()); |
| | | gbc.gridy = 0; |
| | | gbc.gridx = 0; |
| | | gbc.weightx = 0.0; |
| | | gbc.insets = new Insets(10, 10, 10, 0); |
| | | viewOptions.add(l, gbc); |
| | | gbc.insets.left = 5; |
| | | gbc.insets.right = 10; |
| | | connectionHandlers = new JComboBox( |
| | | new DefaultComboBoxModel(new String[]{"fakeconnectionhandlername"})); |
| | | connectionHandlers.addItemListener( |
| | | new IgnoreItemListener(connectionHandlers)); |
| | | connectionHandlers.addItemListener(new ItemListener() |
| | | { |
| | | public void itemStateChanged(ItemEvent ev) |
| | | { |
| | | if (ev.getStateChange() == ItemEvent.SELECTED) |
| | | { |
| | | updateConnectionHandlersPanel( |
| | | getInfo().getServerDescriptor(), |
| | | errorPane.isVisible()); |
| | | } |
| | | } |
| | | }); |
| | | connectionHandlers.setRenderer( |
| | | new CustomComboBoxCellRenderer(connectionHandlers)); |
| | | gbc.gridx ++; |
| | | viewOptions.add(connectionHandlers, gbc); |
| | | gbc.gridx ++; |
| | | gbc.weightx = 1.0; |
| | | gbc.insets.left = 0; |
| | | gbc.insets.right = 0; |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | viewOptions.add(Box.createHorizontalGlue(), gbc); |
| | | |
| | | gbc.gridy = 1; |
| | | gbc.gridx = 0; |
| | | gbc.gridwidth = 1; |
| | | gbc.insets.left = 0; |
| | | gbc.weighty = 0.0; |
| | | gbc.insets = new Insets(0, 0, 0, 0); |
| | | add(viewOptions, gbc); |
| | | |
| | | connectionHandlersTableModel = new ConnectionHandlersMonitoringTableModel(); |
| | | // Add some fake data. |
| | | String[] names = {"First Connection Handler", "Second Connection Handler", |
| | | "Third Connection Handler", "Fourth Connection Handler", |
| | | "Fifth Connection Handler", "Connection Handler with a long name"}; |
| | | |
| | | Set<ConnectionHandlerDescriptor> fakeData = |
| | | new HashSet<ConnectionHandlerDescriptor>(); |
| | | connectionHandlersTableModel.setAttributes(chOperations, false); |
| | | try |
| | | { |
| | | Set<InetAddress> addresses = new HashSet<InetAddress>(); |
| | | addresses.add(InetAddress.getLocalHost()); |
| | | Set<CustomSearchResult> emptySet = Collections.emptySet(); |
| | | for (String name : names) |
| | | { |
| | | fakeData.add(new ConnectionHandlerDescriptor( |
| | | addresses, 1389, Protocol.LDAP, State.ENABLED, name, emptySet)); |
| | | } |
| | | connectionHandlersTableModel.setData(fakeData, 0); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | // Ignore |
| | | } |
| | | connectionHandlersTable = Utilities.createSortableTable( |
| | | connectionHandlersTableModel, |
| | | new DefaultTableCellRenderer()); |
| | | connectionHandlersScroll = Utilities.createScrollPane( |
| | | connectionHandlersTable); |
| | | gbc.insets = new Insets(10, 10, 10, 10); |
| | | gbc.gridy ++; |
| | | gbc.weighty = 1.0; |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | gbc.weightx = 1.0; |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | add(connectionHandlersScroll, gbc); |
| | | gbc.fill = GridBagConstraints.VERTICAL; |
| | | gbc.anchor = GridBagConstraints.CENTER; |
| | | add(lNoConnectionHandlers, gbc); |
| | | updateTableSizes(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Message getTitle() |
| | | { |
| | | return INFO_CTRL_PANEL_CONNECTION_HANDLER_MONITORING_TITLE.get(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public JMenuBar getMenuBar() |
| | | { |
| | | if (menuBar == null) |
| | | { |
| | | menuBar = |
| | | new ConnectionHandlerMonitoringMenuBar(getInfo()); |
| | | } |
| | | return menuBar; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void configurationChanged(ConfigurationChangeEvent ev) |
| | | { |
| | | final ServerDescriptor server = ev.getNewDescriptor(); |
| | | LinkedHashSet<Object> newElements = new LinkedHashSet<Object>(); |
| | | |
| | | newElements.add(new CategorizedComboBoxElement(ALL_CONNECTION_HANDLERS, |
| | | CategorizedComboBoxElement.Type.REGULAR)); |
| | | Set<ConnectionHandlerDescriptor> chs = server.getConnectionHandlers(); |
| | | |
| | | SortedSet<ConnectionHandlerDescriptor> sortedChs = |
| | | new TreeSet<ConnectionHandlerDescriptor>( |
| | | new Comparator<ConnectionHandlerDescriptor>() |
| | | { |
| | | public int compare(ConnectionHandlerDescriptor desc1, |
| | | ConnectionHandlerDescriptor desc2) |
| | | { |
| | | int compare = 0; |
| | | if (desc1.getAddresses().equals(desc2.getAddresses())) |
| | | { |
| | | Integer port1 = new Integer(desc1.getPort()); |
| | | Integer port2 = new Integer(desc2.getPort()); |
| | | compare = port1.compareTo(port2); |
| | | } |
| | | else |
| | | { |
| | | compare = getConnectionHandlerLabel(desc1).compareTo( |
| | | getConnectionHandlerLabel(desc2)); |
| | | } |
| | | return compare; |
| | | } |
| | | }); |
| | | for (ConnectionHandlerDescriptor ch : chs) |
| | | { |
| | | if (ch.getProtocol() != ConnectionHandlerDescriptor.Protocol.LDIF) |
| | | { |
| | | sortedChs.add(ch); |
| | | } |
| | | } |
| | | // Add the administration connector |
| | | sortedChs.add(server.getAdminConnector()); |
| | | |
| | | newElements.add(COMBO_SEPARATOR); |
| | | |
| | | for (ConnectionHandlerDescriptor ch : sortedChs) |
| | | { |
| | | String connectionHandlerLabel = getConnectionHandlerLabel(ch); |
| | | newElements.add(new CategorizedComboBoxElement( |
| | | connectionHandlerLabel, CategorizedComboBoxElement.Type.REGULAR)); |
| | | } |
| | | updateComboBoxModel(newElements, |
| | | (DefaultComboBoxModel)connectionHandlers.getModel()); |
| | | |
| | | boolean displayErrorPane = false; |
| | | Message errorTitle = Message.EMPTY; |
| | | Message errorDetails = Message.EMPTY; |
| | | ServerDescriptor.ServerStatus status = server.getStatus(); |
| | | if (status == ServerDescriptor.ServerStatus.STARTED) |
| | | { |
| | | if (!server.isAuthenticated()) |
| | | { |
| | | MessageBuilder mb = new MessageBuilder(); |
| | | mb.append( |
| | | INFO_CTRL_PANEL_AUTH_REQUIRED_TO_SEE_TRAFFIC_MONITORING_SUMMARY. |
| | | get()); |
| | | mb.append("<br><br>"+getAuthenticateHTML()); |
| | | errorDetails = mb.toMessage(); |
| | | errorTitle = INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_SUMMARY.get(); |
| | | |
| | | displayErrorPane = true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | errorTitle = INFO_CTRL_PANEL_SERVER_NOT_RUNNING_SUMMARY.get(); |
| | | MessageBuilder mb = new MessageBuilder(); |
| | | mb.append( |
| | | INFO_CTRL_PANEL_SERVER_MUST_RUN_TO_SEE_TRAFFIC_MONITORING_SUMMARY. |
| | | get()); |
| | | mb.append("<br><br>"); |
| | | mb.append(getStartServerHTML()); |
| | | errorDetails = mb.toMessage(); |
| | | displayErrorPane = true; |
| | | } |
| | | final boolean fDisplayErrorPane = displayErrorPane; |
| | | final Message fErrorTitle = errorTitle; |
| | | final Message fErrorDetails = errorDetails; |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void run() |
| | | { |
| | | ViewPositions pos = Utilities.getViewPositions( |
| | | ConnectionHandlerMonitoringPanel.this); |
| | | errorPane.setVisible(fDisplayErrorPane); |
| | | if (fDisplayErrorPane) |
| | | { |
| | | updateErrorPane(errorPane, fErrorTitle, |
| | | ColorAndFontConstants.errorTitleFont, fErrorDetails, |
| | | ColorAndFontConstants.defaultFont); |
| | | } |
| | | // TODO: complete update the other table |
| | | if (!firstRealDataSet) |
| | | { |
| | | updateTableSizes(); |
| | | firstRealDataSet = true; |
| | | } |
| | | updateConnectionHandlersPanel(server, fDisplayErrorPane); |
| | | Utilities.updateViewPositions(pos); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Component getPreferredFocusComponent() |
| | | { |
| | | return connectionHandlers; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void okClicked() |
| | | { |
| | | // No ok button |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public GenericDialog.ButtonType getButtonType() |
| | | { |
| | | return GenericDialog.ButtonType.CLOSE; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean requiresBorder() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean requiresScroll() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | private void setChOperationsToDisplay( |
| | | LinkedHashSet<MonitoringAttributes> operations, |
| | | boolean showAverages) |
| | | { |
| | | connectionHandlersTableModel.setAttributes(operations, showAverages); |
| | | connectionHandlersTableModel.forceDataStructureChange(); |
| | | } |
| | | |
| | | private String getConnectionHandlerLabel(ConnectionHandlerDescriptor ch) |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | if (ch.getProtocol() == Protocol.ADMINISTRATION_CONNECTOR) |
| | | { |
| | | sb.append(INFO_CTRL_PANEL_ADMINISTRATION_CONNECTOR_NAME.get( |
| | | ch.getPort())); |
| | | } |
| | | else |
| | | { |
| | | sb.append(ch.getPort()); |
| | | sb.append(" - "); |
| | | switch (ch.getProtocol()) |
| | | { |
| | | case OTHER: |
| | | sb.append(ch.getName()); |
| | | break; |
| | | default: |
| | | sb.append(ch.getProtocol().getDisplayMessage().toString()); |
| | | break; |
| | | } |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | |
| | | /** |
| | | * Displays a dialog allowing the user to select which operations to display. |
| | | * |
| | | */ |
| | | private void operationViewClicked() |
| | | { |
| | | if (operationViewDlg == null) |
| | | { |
| | | operationViewPanel = |
| | | MonitoringAttributesViewPanel.createMonitoringAttributesInstance( |
| | | allowedChOperations); |
| | | operationViewDlg = new GenericDialog(Utilities.getFrame(this), |
| | | operationViewPanel); |
| | | Utilities.centerGoldenMean(operationViewDlg, |
| | | Utilities.getParentDialog(this)); |
| | | operationViewDlg.setModal(true); |
| | | } |
| | | operationViewPanel.setSelectedAttributes(chOperations); |
| | | operationViewDlg.setVisible(true); |
| | | if (!operationViewPanel.isCancelled()) |
| | | { |
| | | boolean showAverages = showAveragesMenu.isSelected(); |
| | | chOperations = operationViewPanel.getAttributes(); |
| | | setChOperationsToDisplay(chOperations, showAverages); |
| | | updateTableSizes(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Updates the contents of the tables depending on whether the averages |
| | | * must be displayed or not. |
| | | * |
| | | */ |
| | | private void showAverageClicked() |
| | | { |
| | | boolean showAverages = showAveragesMenu.isSelected(); |
| | | setChOperationsToDisplay(chOperations, showAverages); |
| | | updateTableSizes(); |
| | | } |
| | | |
| | | private void updateTableSizes() |
| | | { |
| | | Utilities.updateTableSizes(connectionHandlersTable, 8); |
| | | Utilities.updateScrollMode(connectionHandlersScroll, |
| | | connectionHandlersTable); |
| | | } |
| | | |
| | | private void updateConnectionHandlersPanel(ServerDescriptor server, |
| | | boolean errorOccurred) |
| | | { |
| | | Set<ConnectionHandlerDescriptor> cch = |
| | | getFilteredConnectionHandlers(server); |
| | | connectionHandlersTableModel.setData(cch, server.getRunningTime()); |
| | | connectionHandlersScroll.setVisible(!cch.isEmpty() && !errorOccurred); |
| | | lNoConnectionHandlers.setVisible(cch.isEmpty() && !errorOccurred); |
| | | } |
| | | |
| | | private Set<ConnectionHandlerDescriptor> getFilteredConnectionHandlers( |
| | | ServerDescriptor server) |
| | | { |
| | | Set<ConnectionHandlerDescriptor> cchs = |
| | | new HashSet<ConnectionHandlerDescriptor>(); |
| | | if (server != null) |
| | | { |
| | | Object o = connectionHandlers.getSelectedItem(); |
| | | if (o instanceof CategorizedComboBoxElement) |
| | | { |
| | | Object value = ((CategorizedComboBoxElement)o).getValue(); |
| | | if (value.equals(ALL_CONNECTION_HANDLERS)) |
| | | { |
| | | for (ConnectionHandlerDescriptor ch : server.getConnectionHandlers()) |
| | | { |
| | | if (ch.getProtocol() != Protocol.LDIF) |
| | | { |
| | | cchs.add((ConnectionHandlerDescriptor)ch); |
| | | } |
| | | } |
| | | cchs.add(server.getAdminConnector()); |
| | | } |
| | | else |
| | | { |
| | | String name = value.toString(); |
| | | for (ConnectionHandlerDescriptor ch : server.getConnectionHandlers()) |
| | | { |
| | | if (getConnectionHandlerLabel(ch).equals(name)) |
| | | { |
| | | cchs.add((ConnectionHandlerDescriptor)ch); |
| | | break; |
| | | } |
| | | } |
| | | if (cchs.isEmpty()) |
| | | { |
| | | ConnectionHandlerDescriptor adminCh = |
| | | server.getAdminConnector(); |
| | | if (getConnectionHandlerLabel(adminCh).equals(name)) |
| | | { |
| | | cchs.add(adminCh); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return cchs; |
| | | } |
| | | |
| | | /** |
| | | * The specific menu bar of this panel. |
| | | * |
| | | */ |
| | | class ConnectionHandlerMonitoringMenuBar extends MainMenuBar |
| | | { |
| | | private static final long serialVersionUID = 505187831116443370L; |
| | | |
| | | /** |
| | | * Constructor. |
| | | * @param info the control panel info. |
| | | */ |
| | | public ConnectionHandlerMonitoringMenuBar(ControlPanelInfo info) |
| | | { |
| | | super(info); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected void addMenus() |
| | | { |
| | | add(createViewMenuBar()); |
| | | add(createHelpMenuBar()); |
| | | } |
| | | |
| | | /** |
| | | * Creates the view menu bar. |
| | | * @return the view menu bar. |
| | | */ |
| | | protected JMenu createViewMenuBar() |
| | | { |
| | | JMenu menu = Utilities.createMenu( |
| | | INFO_CTRL_PANEL_CONNECTION_HANDLER_VIEW_MENU.get(), |
| | | INFO_CTRL_PANEL_CONNECTION_HANDLER_VIEW_MENU_DESCRIPTION.get()); |
| | | menu.setMnemonic(KeyEvent.VK_V); |
| | | final JMenuItem viewOperations = Utilities.createMenuItem( |
| | | INFO_CTRL_PANEL_OPERATIONS_VIEW.get()); |
| | | menu.add(viewOperations); |
| | | viewOperations.addActionListener(new ActionListener() |
| | | { |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | operationViewClicked(); |
| | | } |
| | | }); |
| | | showAveragesMenu = new JCheckBoxMenuItem( |
| | | INFO_CTRL_PANEL_SHOW_AVERAGES.get().toString()); |
| | | showAveragesMenu.setSelected(false); |
| | | menu.add(showAveragesMenu); |
| | | showAveragesMenu.addActionListener(new ActionListener() |
| | | { |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | showAverageClicked(); |
| | | } |
| | | }); |
| | | return menu; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * This class is used simply to avoid an inset on the left for the |
| | | * elements of the combo box. |
| | | * Since this item is a CategorizedComboBoxElement of type |
| | | * CategorizedComboBoxElement.Type.REGULAR, it has by default an inset on |
| | | * the left. |
| | | */ |
| | | class CustomComboBoxCellRenderer extends CustomListCellRenderer |
| | | { |
| | | /** |
| | | * The constructor. |
| | | * @param combo the combo box to be rendered. |
| | | */ |
| | | CustomComboBoxCellRenderer(JComboBox combo) |
| | | { |
| | | super(combo); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Component getListCellRendererComponent(JList list, Object value, |
| | | int index, boolean isSelected, boolean cellHasFocus) |
| | | { |
| | | Component comp = super.getListCellRendererComponent(list, value, index, |
| | | isSelected, cellHasFocus); |
| | | if (value instanceof CategorizedComboBoxElement) |
| | | { |
| | | CategorizedComboBoxElement element = (CategorizedComboBoxElement)value; |
| | | String name = getStringValue(element); |
| | | ((JLabel)comp).setText(name); |
| | | } |
| | | comp.setFont(defaultFont); |
| | | return comp; |
| | | } |
| | | } |
| | | } |
| | | |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | | import java.awt.event.ActionEvent; |
| | | import java.awt.event.ActionListener; |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.Set; |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | | |
| | | import javax.swing.Box; |
| | | import javax.swing.JButton; |
| | | import javax.swing.JLabel; |
| | | import javax.swing.JScrollPane; |
| | | import javax.swing.JTable; |
| | | import javax.swing.SwingConstants; |
| | | import javax.swing.table.DefaultTableCellRenderer; |
| | | |
| | | import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel. |
| | | DBEnvironmentMonitoringTableModel; |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | /** |
| | | * The panel displaying the database environment monitor panel. |
| | | */ |
| | | public class DBEnvironmentMonitoringPanel extends GeneralMonitoringPanel |
| | | { |
| | | private static final long serialVersionUID = 9031734563723229830L; |
| | | |
| | | private JTable table; |
| | | private DBEnvironmentMonitoringTableModel tableModel; |
| | | private JScrollPane scroll; |
| | | private JLabel noDBsFound; |
| | | private JLabel noMonitoringFound; |
| | | private JButton showOperations; |
| | | |
| | | private LinkedHashSet<String> attributes = new LinkedHashSet<String>(); |
| | | private LinkedHashSet<String> allAttributes = new LinkedHashSet<String>(); |
| | | |
| | | private MonitoringAttributesViewPanel<String> operationViewPanel; |
| | | private GenericDialog operationViewDlg; |
| | | |
| | | /** |
| | | * Default constructor. |
| | | */ |
| | | public DBEnvironmentMonitoringPanel() |
| | | { |
| | | super(); |
| | | createLayout(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Component getPreferredFocusComponent() |
| | | { |
| | | return table; |
| | | } |
| | | |
| | | /** |
| | | * Creates the layout of the panel (but the contents are not populated here). |
| | | */ |
| | | private void createLayout() |
| | | { |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | JLabel lTitle = Utilities.createTitleLabel( |
| | | INFO_CTRL_PANEL_DB_ENVIRONMENT.get()); |
| | | gbc.fill = GridBagConstraints.NONE; |
| | | gbc.anchor = GridBagConstraints.WEST; |
| | | gbc.gridwidth = 2; |
| | | gbc.gridx = 0; |
| | | gbc.gridy = 0; |
| | | gbc.insets.top = 5; |
| | | gbc.insets.bottom = 7; |
| | | add(lTitle, gbc); |
| | | |
| | | gbc.insets.bottom = 0; |
| | | gbc.insets.top = 10; |
| | | gbc.gridy ++; |
| | | gbc.anchor = GridBagConstraints.WEST; |
| | | gbc.gridwidth = 1; |
| | | showOperations = |
| | | Utilities.createButton(INFO_CTRL_PANEL_OPERATIONS_VIEW.get()); |
| | | showOperations.addActionListener(new ActionListener() |
| | | { |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | operationViewClicked(); |
| | | } |
| | | }); |
| | | showOperations.setVisible(false); |
| | | gbc.gridx = 0; |
| | | gbc.weightx = 1.0; |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | add(Box.createHorizontalGlue(), gbc); |
| | | gbc.gridx ++; |
| | | gbc.weightx = 0.0; |
| | | add(showOperations, gbc); |
| | | |
| | | gbc.gridx = 0; |
| | | gbc.gridy ++; |
| | | gbc.gridwidth = 2; |
| | | tableModel = new DBEnvironmentMonitoringTableModel(); |
| | | tableModel.setAttributes(attributes); |
| | | table = Utilities.createSortableTable(tableModel, |
| | | new DefaultTableCellRenderer()); |
| | | scroll = Utilities.createScrollPane(table); |
| | | updateTableSize(); |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | gbc.weightx = 1.0; |
| | | gbc.weighty = 1.0; |
| | | add(scroll, gbc); |
| | | noDBsFound = Utilities.createDefaultLabel( |
| | | INFO_CTRL_PANEL_NO_DBS_FOUND.get()); |
| | | noDBsFound.setHorizontalAlignment(SwingConstants.CENTER); |
| | | add(noDBsFound, gbc); |
| | | noMonitoringFound = Utilities.createDefaultLabel( |
| | | INFO_CTRL_PANEL_NO_DB_MONITORING_FOUND.get()); |
| | | noMonitoringFound.setHorizontalAlignment(SwingConstants.CENTER); |
| | | add(noMonitoringFound, gbc); |
| | | |
| | | setBorder(PANEL_BORDER); |
| | | } |
| | | |
| | | /** |
| | | * Updates the contents of the panel. The code assumes that this is being |
| | | * called from the event thread. |
| | | * |
| | | */ |
| | | public void updateContents() |
| | | { |
| | | boolean backendsFound = false; |
| | | ServerDescriptor server = null; |
| | | if (getInfo() != null) |
| | | { |
| | | server = getInfo().getServerDescriptor(); |
| | | } |
| | | Set<BackendDescriptor> dbBackends = new HashSet<BackendDescriptor>(); |
| | | boolean updateAttributes = allAttributes.isEmpty(); |
| | | SortedSet<String> sortedAttrNames = new TreeSet<String>(); |
| | | if (server != null) |
| | | { |
| | | for (BackendDescriptor backend : server.getBackends()) |
| | | { |
| | | if (backend.getType() == BackendDescriptor.Type.LOCAL_DB) |
| | | { |
| | | dbBackends.add(backend); |
| | | if (updateAttributes) |
| | | { |
| | | sortedAttrNames.addAll(getMonitoringAttributes(backend)); |
| | | } |
| | | } |
| | | } |
| | | backendsFound = !dbBackends.isEmpty(); |
| | | } |
| | | if (updateAttributes) |
| | | { |
| | | allAttributes.addAll(sortedAttrNames); |
| | | for (String attrName : allAttributes) |
| | | { |
| | | attributes.add(attrName); |
| | | if (attributes.size() == 5) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | if (attributes.size() > 0) |
| | | { |
| | | setOperationsToDisplay(attributes); |
| | | updateTableSize(); |
| | | } |
| | | } |
| | | tableModel.setData(dbBackends); |
| | | showOperations.setVisible(backendsFound); |
| | | scroll.setVisible(backendsFound && !allAttributes.isEmpty()); |
| | | noDBsFound.setVisible(!backendsFound); |
| | | noMonitoringFound.setVisible(backendsFound && allAttributes.isEmpty()); |
| | | showOperations.setVisible(allAttributes.size() > 0); |
| | | } |
| | | |
| | | |
| | | private void updateTableSize() |
| | | { |
| | | Utilities.updateTableSizes(table, 8); |
| | | Utilities.updateScrollMode(scroll, table); |
| | | } |
| | | |
| | | /** |
| | | * Displays a dialog allowing the user to select which operations to display. |
| | | * |
| | | */ |
| | | private void operationViewClicked() |
| | | { |
| | | if (operationViewDlg == null) |
| | | { |
| | | operationViewPanel = MonitoringAttributesViewPanel.createStringInstance( |
| | | allAttributes); |
| | | operationViewDlg = new GenericDialog(Utilities.getFrame(this), |
| | | operationViewPanel); |
| | | operationViewDlg.setModal(true); |
| | | Utilities.centerGoldenMean(operationViewDlg, |
| | | Utilities.getParentDialog(this)); |
| | | } |
| | | operationViewPanel.setSelectedAttributes(attributes); |
| | | operationViewDlg.setVisible(true); |
| | | if (!operationViewPanel.isCancelled()) |
| | | { |
| | | attributes = operationViewPanel.getAttributes(); |
| | | setOperationsToDisplay(attributes); |
| | | updateTableSize(); |
| | | } |
| | | } |
| | | |
| | | private void setOperationsToDisplay( |
| | | LinkedHashSet<String> attributes) |
| | | { |
| | | this.attributes = attributes; |
| | | tableModel.setAttributes(attributes); |
| | | tableModel.forceDataStructureChange(); |
| | | } |
| | | |
| | | private Set<String> getMonitoringAttributes(BackendDescriptor backend) |
| | | { |
| | | Set<String> attrNames = new HashSet<String>(); |
| | | if (backend.getMonitoringEntry() != null) |
| | | { |
| | | Set<String> allNames = backend.getMonitoringEntry().getAttributeNames(); |
| | | for (String attrName : allNames) |
| | | { |
| | | if (!attrName.equalsIgnoreCase( |
| | | ServerConstants.OBJECTCLASS_ATTRIBUTE_TYPE_NAME) && |
| | | !attrName.equalsIgnoreCase(ServerConstants.ATTR_COMMON_NAME)) |
| | | { |
| | | attrNames.add(attrName); |
| | | } |
| | | } |
| | | } |
| | | return attrNames; |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import javax.swing.Box; |
| | | import javax.swing.JLabel; |
| | | |
| | | import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; |
| | | import org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes; |
| | | import org.opends.guitools.controlpanel.datamodel.MonitoringAttributes; |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | /** |
| | | * The panel displaying the entry caches monitor panel. |
| | | */ |
| | | public class EntryCachesMonitoringPanel extends GeneralMonitoringPanel |
| | | { |
| | | private static final long serialVersionUID = 9031734563700069830L; |
| | | static List<MonitoringAttributes> ngOperations = |
| | | new ArrayList<MonitoringAttributes>(); |
| | | { |
| | | ngOperations.add(BasicMonitoringAttributes.ENTRY_CACHE_TRIES); |
| | | ngOperations.add(BasicMonitoringAttributes.ENTRY_CACHE_HITS); |
| | | ngOperations.add(BasicMonitoringAttributes.ENTRY_CACHE_HIT_RATIO); |
| | | ngOperations.add(BasicMonitoringAttributes.CURRENT_ENTRY_CACHE_SIZE); |
| | | ngOperations.add(BasicMonitoringAttributes.MAX_ENTRY_CACHE_SIZE); |
| | | ngOperations.add(BasicMonitoringAttributes.CURRENT_ENTRY_CACHE_COUNT); |
| | | ngOperations.add(BasicMonitoringAttributes.MAX_ENTRY_CACHE_COUNT); |
| | | } |
| | | private ArrayList<JLabel> monitoringLabels = |
| | | new ArrayList<JLabel>(); |
| | | { |
| | | for (int i=0; i<ngOperations.size(); i++) |
| | | { |
| | | monitoringLabels.add(Utilities.createDefaultLabel()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Default constructor. |
| | | */ |
| | | public EntryCachesMonitoringPanel() |
| | | { |
| | | super(); |
| | | createLayout(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Component getPreferredFocusComponent() |
| | | { |
| | | return monitoringLabels.get(0); |
| | | } |
| | | |
| | | /** |
| | | * Creates the layout of the panel (but the contents are not populated here). |
| | | */ |
| | | private void createLayout() |
| | | { |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | JLabel lTitle = Utilities.createTitleLabel( |
| | | INFO_CTRL_PANEL_ENTRY_CACHES.get()); |
| | | gbc.fill = GridBagConstraints.NONE; |
| | | gbc.anchor = GridBagConstraints.WEST; |
| | | gbc.gridwidth = 2; |
| | | gbc.gridx = 0; |
| | | gbc.gridy = 0; |
| | | gbc.insets.top = 5; |
| | | gbc.insets.bottom = 7; |
| | | add(lTitle, gbc); |
| | | |
| | | gbc.insets.bottom = 0; |
| | | gbc.insets.top = 10; |
| | | gbc.gridy ++; |
| | | gbc.anchor = GridBagConstraints.WEST; |
| | | gbc.gridwidth = 1; |
| | | for (int i=0; i<ngOperations.size(); i++) |
| | | { |
| | | JLabel l = Utilities.createPrimaryLabel(getLabel(ngOperations.get(i))); |
| | | gbc.gridy ++; |
| | | gbc.insets.left = 0; |
| | | gbc.gridx = 0; |
| | | gbc.weightx = 0.0; |
| | | gbc.gridwidth = 1; |
| | | add(l, gbc); |
| | | gbc.insets.left = 10; |
| | | gbc.gridx = 1; |
| | | gbc.gridwidth = 2; |
| | | add(monitoringLabels.get(i), gbc); |
| | | } |
| | | |
| | | gbc.gridx = 0; |
| | | gbc.gridy ++; |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | gbc.weightx = 1.0; |
| | | gbc.weighty = 1.0; |
| | | gbc.gridwidth = 3; |
| | | add(Box.createGlue(), gbc); |
| | | |
| | | setBorder(PANEL_BORDER); |
| | | } |
| | | |
| | | /** |
| | | * Updates the contents of the panel. |
| | | * |
| | | */ |
| | | public void updateContents() |
| | | { |
| | | ServerDescriptor server = null; |
| | | if (getInfo() != null) |
| | | { |
| | | server = getInfo().getServerDescriptor(); |
| | | } |
| | | CustomSearchResult csr = null; |
| | | if (server != null) |
| | | { |
| | | csr = server.getEntryCachesMonitor(); |
| | | } |
| | | if (csr != null) |
| | | { |
| | | updateMonitoringInfo(ngOperations, monitoringLabels, csr); |
| | | } |
| | | else |
| | | { |
| | | for (JLabel l : monitoringLabels) |
| | | { |
| | | l.setText(NO_VALUE_SET.toString()); |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | |
| | | import javax.swing.border.Border; |
| | | import javax.swing.border.EmptyBorder; |
| | | |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.messages.Message; |
| | | |
| | | /** |
| | | * Abstract class used to refactor some code among the panels that display the |
| | | * contents of the global monitoring. |
| | | * |
| | | */ |
| | | public abstract class GeneralMonitoringPanel extends StatusGenericPanel |
| | | { |
| | | /** |
| | | * The empty border shared by all the panels. |
| | | */ |
| | | protected Border PANEL_BORDER = new EmptyBorder(10, 10, 10, 10); |
| | | |
| | | /** |
| | | * The message to express that the value was not found. |
| | | */ |
| | | protected static Message NO_VALUE_SET = |
| | | INFO_CTRL_PANEL_NO_MONITORING_VALUE.get(); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void configurationChanged(ConfigurationChangeEvent ev) |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Message getTitle() |
| | | { |
| | | return Message.EMPTY; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void okClicked() |
| | | { |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | |
| | | import java.awt.CardLayout; |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | | |
| | | import javax.swing.JPanel; |
| | | |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.messages.Message; |
| | | |
| | | |
| | | /** |
| | | * The panel on the right of the 'General Information' panel. |
| | | * |
| | | */ |
| | | public class GeneralMonitoringRightPanel extends StatusGenericPanel |
| | | { |
| | | private static final long serialVersionUID = -4197460101279681042L; |
| | | |
| | | /** |
| | | * The panel with a CardLayout that contains all the panels. |
| | | */ |
| | | protected JPanel mainPanel; |
| | | |
| | | private RootMonitoringPanel rootPanel = new RootMonitoringPanel(); |
| | | private WorkQueueMonitoringPanel workQueuePanel = |
| | | new WorkQueueMonitoringPanel(); |
| | | private EntryCachesMonitoringPanel entryCachesPanel = |
| | | new EntryCachesMonitoringPanel(); |
| | | private DBEnvironmentMonitoringPanel dbEnvironmentPanel = |
| | | new DBEnvironmentMonitoringPanel(); |
| | | private SystemInformationMonitoringPanel systemInformationPanel = |
| | | new SystemInformationMonitoringPanel(); |
| | | private JavaInformationMonitoringPanel javaInformationPanel = |
| | | new JavaInformationMonitoringPanel(); |
| | | |
| | | /** |
| | | * The panel used to update messages. |
| | | */ |
| | | protected NoItemSelectedPanel noEntryPanel = new NoItemSelectedPanel(); |
| | | |
| | | private final StatusGenericPanel[] panels = |
| | | { |
| | | rootPanel, |
| | | workQueuePanel, |
| | | entryCachesPanel, |
| | | dbEnvironmentPanel, |
| | | systemInformationPanel, |
| | | javaInformationPanel |
| | | }; |
| | | |
| | | /** |
| | | * Default constructor. |
| | | * |
| | | */ |
| | | public GeneralMonitoringRightPanel() |
| | | { |
| | | super(); |
| | | createLayout(); |
| | | } |
| | | |
| | | /** |
| | | * Displays a panel containing a message. |
| | | * @param msg the message. |
| | | * |
| | | */ |
| | | public void displayMessage(Message msg) |
| | | { |
| | | noEntryPanel.setMessage(msg); |
| | | ((CardLayout)mainPanel.getLayout()).show(mainPanel, getTitle(noEntryPanel)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void setInfo(ControlPanelInfo info) |
| | | { |
| | | super.setInfo(info); |
| | | for (StatusGenericPanel panel : panels) |
| | | { |
| | | panel.setInfo(info); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Creates the layout of the panel (but the contents are not populated here). |
| | | */ |
| | | protected void createLayout() |
| | | { |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | CardLayout cardLayout = new CardLayout(); |
| | | mainPanel = new JPanel(cardLayout); |
| | | mainPanel.setOpaque(false); |
| | | noEntryPanel.setMessage( |
| | | INFO_CTRL_PANEL_GENERAL_MONITORING_NO_ITEM_SELECTED.get()); |
| | | JPanel[] panelsWithScroll = |
| | | { |
| | | noEntryPanel, |
| | | rootPanel, |
| | | workQueuePanel, |
| | | entryCachesPanel, |
| | | systemInformationPanel, |
| | | javaInformationPanel |
| | | }; |
| | | JPanel[] panelsWithNoScroll = |
| | | { |
| | | dbEnvironmentPanel |
| | | }; |
| | | for (JPanel panel : panelsWithScroll) |
| | | { |
| | | mainPanel.add(Utilities.createBorderLessScrollBar(panel), |
| | | getTitle(panel)); |
| | | } |
| | | for (JPanel panel : panelsWithNoScroll) |
| | | { |
| | | mainPanel.add(panel, getTitle(panel)); |
| | | } |
| | | cardLayout.show(mainPanel, getTitle(noEntryPanel)); |
| | | gbc.gridx = 0; |
| | | gbc.gridy = 0; |
| | | gbc.weightx = 1.0; |
| | | gbc.weighty = 1.0; |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | add(mainPanel, gbc); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void okClicked() |
| | | { |
| | | // No ok button |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public GenericDialog.ButtonType getButtonType() |
| | | { |
| | | return GenericDialog.ButtonType.NO_BUTTON; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Message getTitle() |
| | | { |
| | | return Message.EMPTY; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Component getPreferredFocusComponent() |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void configurationChanged(ConfigurationChangeEvent ev) |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Updates the contents of the panel with the root monitoring information. |
| | | * |
| | | */ |
| | | public void updateRoot() |
| | | { |
| | | rootPanel.updateContents(); |
| | | ((CardLayout)mainPanel.getLayout()).show(mainPanel, |
| | | getTitle(rootPanel)); |
| | | } |
| | | |
| | | /** |
| | | * Updates the contents of the panel with the system information monitoring. |
| | | * |
| | | */ |
| | | public void updateSystemInformation() |
| | | { |
| | | systemInformationPanel.updateContents(); |
| | | ((CardLayout)mainPanel.getLayout()).show(mainPanel, |
| | | getTitle(systemInformationPanel)); |
| | | } |
| | | |
| | | /** |
| | | * Updates the contents of the panel with the work queue monitoring |
| | | * information. |
| | | * |
| | | */ |
| | | public void updateWorkQueue() |
| | | { |
| | | workQueuePanel.updateContents(); |
| | | ((CardLayout)mainPanel.getLayout()).show(mainPanel, |
| | | getTitle(workQueuePanel)); |
| | | } |
| | | |
| | | /** |
| | | * Updates the contents of the panel with the entry caches monitoring |
| | | * information. |
| | | * |
| | | */ |
| | | public void updateEntryCaches() |
| | | { |
| | | entryCachesPanel.updateContents(); |
| | | ((CardLayout)mainPanel.getLayout()).show(mainPanel, |
| | | getTitle(entryCachesPanel)); |
| | | } |
| | | |
| | | /** |
| | | * Updates the contents of the panel with the database environment monitoring |
| | | * information. |
| | | * |
| | | */ |
| | | public void updateDBEnvironment() |
| | | { |
| | | dbEnvironmentPanel.updateContents(); |
| | | ((CardLayout)mainPanel.getLayout()).show(mainPanel, |
| | | getTitle(dbEnvironmentPanel)); |
| | | } |
| | | |
| | | /** |
| | | * Updates the contents of the panel with the JAVA information. |
| | | * |
| | | */ |
| | | public void updateJavaInformation() |
| | | { |
| | | javaInformationPanel.updateContents(); |
| | | ((CardLayout)mainPanel.getLayout()).show(mainPanel, |
| | | getTitle(javaInformationPanel)); |
| | | } |
| | | |
| | | /** |
| | | * Returns the title for a given panel. It will be used to update the |
| | | * CardLayout. |
| | | * @param panel the panel we want to get the title from. |
| | | * @return the title for a given panel. |
| | | */ |
| | | protected String getTitle(JPanel panel) |
| | | { |
| | | return panel.getClass().toString(); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | | import java.awt.GridBagLayout; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | | |
| | | import javax.swing.Box; |
| | | import javax.swing.JComponent; |
| | | import javax.swing.JEditorPane; |
| | | import javax.swing.JLabel; |
| | | import javax.swing.JPanel; |
| | | import javax.swing.border.EmptyBorder; |
| | | import javax.swing.event.ChangeEvent; |
| | | import javax.swing.event.ChangeListener; |
| | | import javax.swing.text.JTextComponent; |
| | | |
| | | import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; |
| | | import org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes; |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | | import org.opends.guitools.controlpanel.ui.components.BasicExpander; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | /** |
| | | * The panel displaying the java monitoring information. |
| | | */ |
| | | public class JavaInformationMonitoringPanel extends GeneralMonitoringPanel |
| | | { |
| | | private static final long serialVersionUID = 9031734563799969830L; |
| | | private List<BasicMonitoringAttributes> generalAttributes = |
| | | new ArrayList<BasicMonitoringAttributes>(); |
| | | { |
| | | generalAttributes.add(BasicMonitoringAttributes.JVM_VERSION); |
| | | generalAttributes.add(BasicMonitoringAttributes.JVM_VENDOR); |
| | | generalAttributes.add(BasicMonitoringAttributes.JVM_ARCHITECTURE); |
| | | generalAttributes.add(BasicMonitoringAttributes.JVM_ARGUMENTS); |
| | | generalAttributes.add(BasicMonitoringAttributes.CLASS_PATH); |
| | | generalAttributes.add(BasicMonitoringAttributes.JAVA_VERSION); |
| | | generalAttributes.add(BasicMonitoringAttributes.JAVA_VENDOR); |
| | | } |
| | | private List<BasicMonitoringAttributes> extraAttributes = |
| | | new ArrayList<BasicMonitoringAttributes>(); |
| | | { |
| | | extraAttributes.add(BasicMonitoringAttributes.CLASS_PATH); |
| | | extraAttributes.add(BasicMonitoringAttributes.JAVA_VERSION); |
| | | extraAttributes.add(BasicMonitoringAttributes.JAVA_VENDOR); |
| | | } |
| | | private ArrayList<JComponent> generalMonitoringComps = |
| | | new ArrayList<JComponent>(); |
| | | { |
| | | for (int i=0; i<generalAttributes.size(); i++) |
| | | { |
| | | if ((generalAttributes.get(i) == BasicMonitoringAttributes.CLASS_PATH) || |
| | | (generalAttributes.get(i) == BasicMonitoringAttributes.JVM_ARGUMENTS)) |
| | | { |
| | | JEditorPane pane = new JEditorPane(); |
| | | pane.setEditable(false); |
| | | pane.setBorder(new EmptyBorder(0, 0, 0, 0)); |
| | | pane.setOpaque(false); |
| | | pane.setFocusCycleRoot(false); |
| | | generalMonitoringComps.add(pane); |
| | | } |
| | | else |
| | | { |
| | | generalMonitoringComps.add(Utilities.createDefaultLabel()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private List<String> memoryAttributes = new ArrayList<String>(); |
| | | private List<JLabel> memoryLabels = new ArrayList<JLabel>(); |
| | | private JPanel memoryPanel; |
| | | |
| | | /** |
| | | * Default constructor. |
| | | */ |
| | | public JavaInformationMonitoringPanel() |
| | | { |
| | | super(); |
| | | createLayout(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Component getPreferredFocusComponent() |
| | | { |
| | | return generalMonitoringComps.get(0); |
| | | } |
| | | |
| | | /** |
| | | * Creates the layout of the panel (but the contents are not populated here). |
| | | */ |
| | | private void createLayout() |
| | | { |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | JLabel lTitle = Utilities.createTitleLabel( |
| | | INFO_CTRL_PANEL_JAVA_INFORMATION.get()); |
| | | gbc.fill = GridBagConstraints.NONE; |
| | | gbc.anchor = GridBagConstraints.WEST; |
| | | gbc.gridwidth = 2; |
| | | gbc.gridx = 0; |
| | | gbc.gridy = 0; |
| | | gbc.insets.top = 5; |
| | | gbc.insets.bottom = 7; |
| | | add(lTitle, gbc); |
| | | |
| | | gbc.insets.bottom = 0; |
| | | gbc.insets.top = 10; |
| | | gbc.gridy ++; |
| | | gbc.anchor = GridBagConstraints.WEST; |
| | | gbc.gridwidth = 1; |
| | | for (int i=0; i<generalAttributes.size(); i++) |
| | | { |
| | | if (extraAttributes.contains(generalAttributes.get(i))) |
| | | { |
| | | continue; |
| | | } |
| | | JLabel l = Utilities.createPrimaryLabel( |
| | | getLabel(generalAttributes.get(i))); |
| | | gbc.gridy ++; |
| | | gbc.insets.left = 0; |
| | | gbc.insets.right = 0; |
| | | gbc.gridx = 0; |
| | | gbc.weightx = 0.0; |
| | | gbc.gridwidth = 1; |
| | | gbc.fill = GridBagConstraints.NONE; |
| | | boolean isTextComponent = |
| | | generalMonitoringComps.get(i) instanceof JTextComponent; |
| | | if (isTextComponent) |
| | | { |
| | | gbc.anchor = GridBagConstraints.NORTHWEST; |
| | | } |
| | | else |
| | | { |
| | | gbc.anchor = GridBagConstraints.WEST; |
| | | } |
| | | add(l, gbc); |
| | | gbc.insets.left = 10; |
| | | gbc.gridx = 1; |
| | | if (isTextComponent) |
| | | { |
| | | gbc.insets.right = 10; |
| | | gbc.weightx = 1.0; |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | add(generalMonitoringComps.get(i), gbc); |
| | | } |
| | | else |
| | | { |
| | | gbc.weightx = 0.0; |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | add(generalMonitoringComps.get(i), gbc); |
| | | } |
| | | } |
| | | |
| | | final BasicExpander extraExpander = new BasicExpander( |
| | | INFO_CTRL_PANEL_EXTRA_JAVA_ATTRIBUTES.get()); |
| | | gbc.gridwidth = 2; |
| | | gbc.gridx = 0; |
| | | gbc.weighty = 0.0; |
| | | gbc.insets.left = 0; |
| | | gbc.weightx = 1.0; |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | gbc.gridy ++; |
| | | add(extraExpander, gbc); |
| | | final JPanel extraGeneralPanel = new JPanel(new GridBagLayout()); |
| | | gbc.insets.left = 15; |
| | | gbc.gridy ++; |
| | | add(extraGeneralPanel, gbc); |
| | | extraGeneralPanel.setOpaque(false); |
| | | extraGeneralPanel.setVisible(false); |
| | | |
| | | final BasicExpander memoryExpander = new BasicExpander( |
| | | INFO_CTRL_PANEL_JAVA_MEMORY_ATTRIBUTES.get()); |
| | | gbc.gridy ++; |
| | | gbc.insets.left = 0; |
| | | add(memoryExpander, gbc); |
| | | memoryPanel = new JPanel(new GridBagLayout()); |
| | | gbc.insets.left = 15; |
| | | gbc.gridy ++; |
| | | add(memoryPanel, gbc); |
| | | memoryPanel.setOpaque(false); |
| | | memoryPanel.setVisible(false); |
| | | |
| | | GridBagConstraints gbc1 = new GridBagConstraints(); |
| | | gbc1.fill = GridBagConstraints.HORIZONTAL; |
| | | gbc1.gridy = 0; |
| | | gbc1.gridx = 0; |
| | | gbc1.gridwidth = 1; |
| | | |
| | | for (int i=0; i<extraAttributes.size(); i++) |
| | | { |
| | | int index = generalAttributes.indexOf(extraAttributes.get(i)); |
| | | JLabel l = Utilities.createPrimaryLabel( |
| | | getLabel(extraAttributes.get(i))); |
| | | gbc1.insets.left = 0; |
| | | gbc1.insets.right = 0; |
| | | gbc1.gridx = 0; |
| | | gbc1.weightx = 0.0; |
| | | gbc1.gridwidth = 1; |
| | | gbc1.fill = GridBagConstraints.NONE; |
| | | boolean isTextComponent = |
| | | generalMonitoringComps.get(index) instanceof JTextComponent; |
| | | if (isTextComponent) |
| | | { |
| | | gbc1.anchor = GridBagConstraints.NORTHWEST; |
| | | } |
| | | else |
| | | { |
| | | gbc1.anchor = GridBagConstraints.WEST; |
| | | } |
| | | extraGeneralPanel.add(l, gbc1); |
| | | gbc1.insets.left = 10; |
| | | gbc1.gridx = 1; |
| | | if (isTextComponent) |
| | | { |
| | | gbc1.insets.right = 10; |
| | | gbc1.weightx = 1.0; |
| | | gbc1.fill = GridBagConstraints.BOTH; |
| | | extraGeneralPanel.add(generalMonitoringComps.get(index), gbc1); |
| | | } |
| | | else |
| | | { |
| | | gbc1.weightx = 1.0; |
| | | gbc1.fill = GridBagConstraints.HORIZONTAL; |
| | | extraGeneralPanel.add(generalMonitoringComps.get(index), gbc1); |
| | | } |
| | | gbc1.insets.top = 10; |
| | | gbc1.gridy ++; |
| | | } |
| | | ChangeListener changeListener = new ChangeListener() |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void stateChanged(ChangeEvent e) |
| | | { |
| | | extraGeneralPanel.setVisible(extraExpander.isSelected()); |
| | | } |
| | | }; |
| | | extraExpander.addChangeListener(changeListener); |
| | | |
| | | changeListener = new ChangeListener() |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void stateChanged(ChangeEvent e) |
| | | { |
| | | memoryPanel.setVisible(memoryExpander.isSelected()); |
| | | } |
| | | }; |
| | | memoryExpander.addChangeListener(changeListener); |
| | | |
| | | gbc.gridx = 0; |
| | | gbc.gridy ++; |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | gbc.weightx = 1.0; |
| | | gbc.weighty = 1.0; |
| | | gbc.gridwidth = 2; |
| | | add(Box.createGlue(), gbc); |
| | | |
| | | setBorder(PANEL_BORDER); |
| | | } |
| | | |
| | | /** |
| | | * Updates the contents of the panel. |
| | | * |
| | | */ |
| | | public void updateContents() |
| | | { |
| | | ServerDescriptor server = null; |
| | | if (getInfo() != null) |
| | | { |
| | | server = getInfo().getServerDescriptor(); |
| | | } |
| | | CustomSearchResult csrSystem = null; |
| | | CustomSearchResult csrMemory = null; |
| | | if (server != null) |
| | | { |
| | | csrSystem = server.getSystemInformationMonitor(); |
| | | csrMemory = server.getJvmMemoryUsageMonitor(); |
| | | } |
| | | if (csrSystem != null) |
| | | { |
| | | for (int i=0 ; i<generalAttributes.size(); i++) |
| | | { |
| | | String value = |
| | | getMonitoringValue(generalAttributes.get(i), csrSystem); |
| | | JComponent l = generalMonitoringComps.get(i); |
| | | if (l instanceof JLabel) |
| | | { |
| | | ((JLabel)l).setText(value); |
| | | } |
| | | else if (l instanceof JTextComponent) |
| | | { |
| | | ((JTextComponent)l).setText(value); |
| | | } |
| | | else |
| | | { |
| | | throw new IllegalStateException("Unexpected component: "+l); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (JComponent l : generalMonitoringComps) |
| | | { |
| | | if (l instanceof JLabel) |
| | | { |
| | | ((JLabel)l).setText(NO_VALUE_SET.toString()); |
| | | } |
| | | else if (l instanceof JTextComponent) |
| | | { |
| | | ((JTextComponent)l).setText(NO_VALUE_SET.toString()); |
| | | } |
| | | else |
| | | { |
| | | throw new IllegalStateException("Unexpected component: "+l); |
| | | } |
| | | } |
| | | } |
| | | if (csrMemory != null) |
| | | { |
| | | if (memoryAttributes.isEmpty()) |
| | | { |
| | | Set<String> allNames = csrMemory.getAttributeNames(); |
| | | SortedSet<String> sortedNames = new TreeSet<String>(); |
| | | for (String attrName : allNames) |
| | | { |
| | | if (!attrName.equalsIgnoreCase( |
| | | ServerConstants.OBJECTCLASS_ATTRIBUTE_TYPE_NAME) && |
| | | !attrName.equalsIgnoreCase(ServerConstants.ATTR_COMMON_NAME)) |
| | | { |
| | | sortedNames.add(attrName); |
| | | } |
| | | } |
| | | memoryAttributes.addAll(sortedNames); |
| | | |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | gbc.gridx = 0; |
| | | gbc.gridy = 0; |
| | | gbc.anchor = GridBagConstraints.WEST; |
| | | gbc.gridwidth = 1; |
| | | |
| | | for (String attrName : memoryAttributes) |
| | | { |
| | | JLabel l = Utilities.createPrimaryLabel( |
| | | INFO_CTRL_PANEL_OPERATION_NAME_AS_LABEL.get(attrName)); |
| | | gbc.insets.left = 0; |
| | | gbc.insets.right = 0; |
| | | gbc.gridx = 0; |
| | | gbc.weightx = 0.0; |
| | | gbc.fill = GridBagConstraints.NONE; |
| | | memoryPanel.add(l, gbc); |
| | | gbc.insets.left = 10; |
| | | gbc.gridx = 1; |
| | | gbc.weightx = 1.0; |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | JLabel valueLabel = Utilities.createDefaultLabel(); |
| | | memoryLabels.add(valueLabel); |
| | | memoryPanel.add(valueLabel, gbc); |
| | | gbc.gridy ++; |
| | | gbc.insets.top = 10; |
| | | } |
| | | } |
| | | |
| | | for (int i=0; i<memoryAttributes.size() ; i++) |
| | | { |
| | | Object value = Utilities.getFirstMonitoringValue( |
| | | csrMemory, |
| | | memoryAttributes.get(i)); |
| | | if (value != null) |
| | | { |
| | | memoryLabels.get(i).setText(value.toString()); |
| | | } |
| | | else |
| | | { |
| | | memoryLabels.get(i).setText(NO_VALUE_SET.toString()); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (JLabel l : memoryLabels) |
| | | { |
| | | l.setText(NO_VALUE_SET.toString()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | |
| | | INFO_CTRL_PANEL_ACTION_RESTORE.get() |
| | | }, |
| | | { |
| | | INFO_CTRL_PANEL_CATEGORY_SCHEMA.get(), |
| | | INFO_CTRL_PANEL_ACTION_MANAGE_SCHEMA.get() |
| | | INFO_CTRL_PANEL_CATEGORY_SCHEMA.get(), |
| | | INFO_CTRL_PANEL_ACTION_MANAGE_SCHEMA.get() |
| | | }, |
| | | { |
| | | INFO_CTRL_PANEL_CATEGORY_INDEXES.get(), |
| | | INFO_CTRL_PANEL_ACTION_MANAGE_INDEXES.get(), |
| | | INFO_CTRL_PANEL_ACTION_VERIFY_INDEXES.get(), |
| | | INFO_CTRL_PANEL_ACTION_REBUILD_INDEXES.get() |
| | | INFO_CTRL_PANEL_CATEGORY_INDEXES.get(), |
| | | INFO_CTRL_PANEL_ACTION_MANAGE_INDEXES.get(), |
| | | INFO_CTRL_PANEL_ACTION_VERIFY_INDEXES.get(), |
| | | INFO_CTRL_PANEL_ACTION_REBUILD_INDEXES.get() |
| | | }, |
| | | { |
| | | INFO_CTRL_PANEL_CATEGORY_RUNTIME_OPTIONS.get(), |
| | | INFO_CTRL_PANEL_ACTION_JAVA_SETTINGS.get(), |
| | | INFO_CTRL_PANEL_ACTION_WINDOWS_SERVICE.get() |
| | | INFO_CTRL_PANEL_CATEGORY_MONITORING.get(), |
| | | INFO_CTRL_PANEL_BROWSE_GENERAL_MONITORING.get(), |
| | | INFO_CTRL_PANEL_CONNECTION_HANDLER_MONITORING.get() |
| | | }, |
| | | { |
| | | INFO_CTRL_PANEL_CATEGORY_RUNTIME_OPTIONS.get(), |
| | | INFO_CTRL_PANEL_ACTION_JAVA_SETTINGS.get(), |
| | | INFO_CTRL_PANEL_ACTION_WINDOWS_SERVICE.get() |
| | | } |
| | | }; |
| | | } |
| | |
| | | INFO_CTRL_PANEL_ACTION_RESTORE.get() |
| | | }, |
| | | { |
| | | INFO_CTRL_PANEL_CATEGORY_SCHEMA.get(), |
| | | INFO_CTRL_PANEL_ACTION_MANAGE_SCHEMA.get() |
| | | INFO_CTRL_PANEL_CATEGORY_SCHEMA.get(), |
| | | INFO_CTRL_PANEL_ACTION_MANAGE_SCHEMA.get() |
| | | }, |
| | | { |
| | | INFO_CTRL_PANEL_CATEGORY_INDEXES.get(), |
| | | INFO_CTRL_PANEL_ACTION_MANAGE_INDEXES.get(), |
| | | INFO_CTRL_PANEL_ACTION_VERIFY_INDEXES.get(), |
| | | INFO_CTRL_PANEL_ACTION_REBUILD_INDEXES.get() |
| | | INFO_CTRL_PANEL_CATEGORY_INDEXES.get(), |
| | | INFO_CTRL_PANEL_ACTION_MANAGE_INDEXES.get(), |
| | | INFO_CTRL_PANEL_ACTION_VERIFY_INDEXES.get(), |
| | | INFO_CTRL_PANEL_ACTION_REBUILD_INDEXES.get() |
| | | }, |
| | | { |
| | | INFO_CTRL_PANEL_CATEGORY_RUNTIME_OPTIONS.get(), |
| | | INFO_CTRL_PANEL_ACTION_JAVA_SETTINGS.get() |
| | | INFO_CTRL_PANEL_CATEGORY_MONITORING.get(), |
| | | INFO_CTRL_PANEL_BROWSE_GENERAL_MONITORING.get(), |
| | | INFO_CTRL_PANEL_CONNECTION_HANDLER_MONITORING.get() |
| | | }, |
| | | { |
| | | INFO_CTRL_PANEL_CATEGORY_RUNTIME_OPTIONS.get(), |
| | | INFO_CTRL_PANEL_ACTION_JAVA_SETTINGS.get() |
| | | } |
| | | }; |
| | | } |
| | |
| | | classes.add(BrowseIndexPanel.class); |
| | | classes.add(VerifyIndexPanel.class); |
| | | classes.add(RebuildIndexPanel.class); |
| | | classes.add(BrowseGeneralMonitoringPanel.class); |
| | | classes.add(ConnectionHandlerMonitoringPanel.class); |
| | | classes.add(JavaPropertiesPanel.class); |
| | | if (Utilities.isWindows()) |
| | | { |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashSet; |
| | | |
| | | import javax.swing.Box; |
| | | import javax.swing.JCheckBox; |
| | | |
| | | import org.opends.guitools.controlpanel.datamodel.MonitoringAttributes; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.messages.Message; |
| | | |
| | | /** |
| | | * |
| | | * The panel that allows the user to select which attributes must be displayed |
| | | * in the traffic monitoring tables. |
| | | * |
| | | * @param <T> the type of the objects that this panel manages. For now it only |
| | | * manages String and MonitoringAttribute objects. |
| | | */ |
| | | public class MonitoringAttributesViewPanel<T> extends StatusGenericPanel |
| | | { |
| | | private static final long serialVersionUID = 6462932163745559L; |
| | | |
| | | private LinkedHashSet<T> selectedAttributes = new LinkedHashSet<T>(); |
| | | |
| | | private LinkedHashSet<T> monitoringAttributes; |
| | | |
| | | private boolean isCancelled = true; |
| | | |
| | | // Note: the order of the checkboxes and the elements in the Attributes |
| | | // enumeration will be the same. |
| | | private JCheckBox[] checkboxes = {}; |
| | | |
| | | /** |
| | | * Creates an instance of this panel that uses String as attributes. |
| | | * @param attributes the list of possible attributes. |
| | | * @return an instance of this panel that uses String as attributes. |
| | | */ |
| | | public static MonitoringAttributesViewPanel<String> |
| | | createStringInstance(LinkedHashSet<String> attributes) |
| | | { |
| | | return new MonitoringAttributesViewPanel<String>(attributes); |
| | | } |
| | | |
| | | /** |
| | | * Creates an instance of this panel that uses MonitoringAttributes as |
| | | * attributes. |
| | | * @param attributes the list of possible attributes. |
| | | * @return an instance of this panel that uses String as attributes. |
| | | */ |
| | | public static MonitoringAttributesViewPanel<MonitoringAttributes> |
| | | createMonitoringAttributesInstance( |
| | | LinkedHashSet<MonitoringAttributes> attributes) |
| | | { |
| | | return new MonitoringAttributesViewPanel<MonitoringAttributes>(attributes); |
| | | } |
| | | |
| | | /** |
| | | * Default constructor. |
| | | * @param attributes the attributes that will be proposed to the user. |
| | | * |
| | | */ |
| | | protected MonitoringAttributesViewPanel( |
| | | LinkedHashSet<T> attributes) |
| | | { |
| | | super(); |
| | | monitoringAttributes = new LinkedHashSet<T>(); |
| | | monitoringAttributes.addAll(attributes); |
| | | createLayout(); |
| | | } |
| | | |
| | | /** |
| | | * Sets the attributes that must be selected in this dialog. |
| | | * @param selectedAttributes the selected attributes. |
| | | */ |
| | | public void setSelectedAttributes( |
| | | Collection<T> selectedAttributes) |
| | | { |
| | | int i = 0; |
| | | for (T attribute : monitoringAttributes) |
| | | { |
| | | checkboxes[i].setSelected(selectedAttributes.contains(attribute)); |
| | | i++; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Creates the layout of the panel (but the contents are not populated here). |
| | | */ |
| | | private void createLayout() |
| | | { |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | gbc.gridy = 0; |
| | | int nCols = monitoringAttributes.size() > 30 ? 3 : 2; |
| | | |
| | | gbc.gridwidth = nCols; |
| | | gbc.gridx = 0; |
| | | add(Utilities.createPrimaryLabel( |
| | | INFO_CTRL_PANEL_OPERATION_VIEW_LABEL.get()), gbc); |
| | | gbc.gridy ++; |
| | | gbc.gridwidth = 1; |
| | | gbc.insets.top = 10; |
| | | |
| | | checkboxes = new JCheckBox[monitoringAttributes.size()]; |
| | | |
| | | int i = 0; |
| | | Iterator<T> ops = monitoringAttributes.iterator(); |
| | | while (ops.hasNext()) |
| | | { |
| | | T operation = ops.next(); |
| | | Message m = getMessage(operation); |
| | | |
| | | JCheckBox cb = Utilities.createCheckBox(m); |
| | | gbc.gridx = 0; |
| | | gbc.weightx = 0.0; |
| | | gbc.insets.left = 0; |
| | | checkboxes[i] = cb; |
| | | add(checkboxes[i], gbc); |
| | | gbc.weightx = 1.0; |
| | | gbc.insets.left = 40; |
| | | while (gbc.gridx + 1 < nCols) |
| | | { |
| | | gbc.gridx ++; |
| | | if (i + 1 >= checkboxes.length) |
| | | { |
| | | add(Box.createHorizontalGlue(), gbc); |
| | | } |
| | | else |
| | | { |
| | | operation = ops.next(); |
| | | m = getMessage(operation); |
| | | cb = Utilities.createCheckBox(m); |
| | | checkboxes[i+1] = cb; |
| | | add(checkboxes[i+1], gbc); |
| | | i ++; |
| | | checkboxes[i].setSelected(true); |
| | | } |
| | | } |
| | | gbc.gridy ++; |
| | | i++; |
| | | } |
| | | gbc.gridx = 0; |
| | | gbc.gridwidth = nCols; |
| | | gbc.weighty = 1.0; |
| | | gbc.fill = GridBagConstraints.VERTICAL; |
| | | add(Box.createVerticalGlue(), gbc); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Message getTitle() |
| | | { |
| | | return INFO_CTRL_PANEL_ATTRIBUTE_VIEW_OPTIONS_TITLE.get(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void configurationChanged(ConfigurationChangeEvent ev) |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Component getPreferredFocusComponent() |
| | | { |
| | | return checkboxes[0]; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void toBeDisplayed(boolean visible) |
| | | { |
| | | if (visible) |
| | | { |
| | | isCancelled = true; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void okClicked() |
| | | { |
| | | // Check that at least one checkbox is selected. |
| | | selectedAttributes.clear(); |
| | | int i = 0; |
| | | for (T operation : monitoringAttributes) |
| | | { |
| | | if (checkboxes[i].isSelected()) |
| | | { |
| | | selectedAttributes.add(operation); |
| | | } |
| | | i++; |
| | | } |
| | | if (selectedAttributes.isEmpty()) |
| | | { |
| | | ArrayList<Message> errors = new ArrayList<Message>(); |
| | | errors.add(INFO_CTRL_PANEL_NO_OPERATION_SELECTED.get()); |
| | | super.displayErrorDialog(errors); |
| | | } |
| | | else |
| | | { |
| | | isCancelled = false; |
| | | super.closeClicked(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public GenericDialog.ButtonType getButtonType() |
| | | { |
| | | return GenericDialog.ButtonType.OK_CANCEL; |
| | | } |
| | | |
| | | /** |
| | | * Returns <CODE>true</CODE> if the user closed the dialog by cancelling it |
| | | * and <CODE>false</CODE> otherwise. |
| | | * @return <CODE>true</CODE> if the user closed the dialog by cancelling it |
| | | * and <CODE>false</CODE> otherwise. |
| | | */ |
| | | public boolean isCancelled() |
| | | { |
| | | return isCancelled; |
| | | } |
| | | |
| | | /** |
| | | * Returns the list of attributes that the user selected. |
| | | * @return the list of attributes that the user selected. |
| | | */ |
| | | public LinkedHashSet<T> getAttributes() |
| | | { |
| | | return selectedAttributes; |
| | | } |
| | | |
| | | /** |
| | | * Returns the message for the provided operation. |
| | | * @param operation the operation. |
| | | * @return the message for the provided operation. |
| | | */ |
| | | protected Message getMessage(T operation) |
| | | { |
| | | Message m; |
| | | if (operation instanceof MonitoringAttributes) |
| | | { |
| | | m = ((MonitoringAttributes)operation).getMessage(); |
| | | } |
| | | else |
| | | { |
| | | m = Message.raw(operation.toString()); |
| | | } |
| | | return m; |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.messages.BackendMessages.INFO_MONITOR_UPTIME; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | | import java.util.Date; |
| | | |
| | | import javax.swing.Box; |
| | | import javax.swing.JLabel; |
| | | |
| | | import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; |
| | | import org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes; |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | | import org.opends.guitools.controlpanel.util.ConfigFromDirContext; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.messages.Message; |
| | | |
| | | /** |
| | | * The panel displaying the root monitor panel. |
| | | */ |
| | | public class RootMonitoringPanel extends GeneralMonitoringPanel |
| | | { |
| | | private static final long serialVersionUID = 9031734563746269830L; |
| | | |
| | | private JLabel openConnections = Utilities.createDefaultLabel(); |
| | | private JLabel maxConnections = Utilities.createDefaultLabel(); |
| | | private JLabel totalConnections = Utilities.createDefaultLabel(); |
| | | private JLabel startTime = Utilities.createDefaultLabel(); |
| | | private JLabel upTime = Utilities.createDefaultLabel(); |
| | | private JLabel version = Utilities.createDefaultLabel(); |
| | | |
| | | /** |
| | | * Default constructor. |
| | | */ |
| | | public RootMonitoringPanel() |
| | | { |
| | | super(); |
| | | createLayout(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Component getPreferredFocusComponent() |
| | | { |
| | | return openConnections; |
| | | } |
| | | |
| | | /** |
| | | * Creates the layout of the panel (but the contents are not populated here). |
| | | */ |
| | | private void createLayout() |
| | | { |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | gbc.gridy ++; |
| | | JLabel lTitle = Utilities.createTitleLabel( |
| | | INFO_CTRL_PANEL_GENERAL_MONITORING_ROOT.get()); |
| | | gbc.fill = GridBagConstraints.NONE; |
| | | gbc.anchor = GridBagConstraints.WEST; |
| | | gbc.gridwidth = 2; |
| | | gbc.gridy = 0; |
| | | gbc.insets.top = 5; |
| | | gbc.insets.bottom = 7; |
| | | add(lTitle, gbc); |
| | | |
| | | gbc.insets.bottom = 0; |
| | | gbc.insets.top = 10; |
| | | Message[] labels = { |
| | | INFO_CTRL_PANEL_OPEN_CONNECTIONS_LABEL.get(), |
| | | INFO_CTRL_PANEL_MAX_CONNECTIONS_LABEL.get(), |
| | | INFO_CTRL_PANEL_TOTAL_CONNECTIONS_LABEL.get(), |
| | | INFO_CTRL_PANEL_START_TIME_LABEL.get(), |
| | | INFO_CTRL_PANEL_UP_TIME_LABEL.get(), |
| | | INFO_CTRL_PANEL_OPENDS_VERSION_LABEL.get() |
| | | }; |
| | | JLabel[] values = { |
| | | openConnections, |
| | | maxConnections, |
| | | totalConnections, |
| | | startTime, |
| | | upTime, |
| | | version |
| | | }; |
| | | gbc.gridy ++; |
| | | gbc.anchor = GridBagConstraints.WEST; |
| | | gbc.gridwidth = 1; |
| | | for (int i=0; i < labels.length; i++) |
| | | { |
| | | gbc.insets.left = 0; |
| | | gbc.gridx = 0; |
| | | JLabel l = Utilities.createPrimaryLabel(labels[i]); |
| | | add(l, gbc); |
| | | gbc.insets.left = 10; |
| | | gbc.gridx = 1; |
| | | add(values[i], gbc); |
| | | gbc.gridy ++; |
| | | } |
| | | |
| | | gbc.gridwidth = 2; |
| | | gbc.gridx = 0; |
| | | gbc.gridy ++; |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | gbc.weightx = 1.0; |
| | | gbc.weighty = 1.0; |
| | | add(Box.createGlue(), gbc); |
| | | |
| | | setBorder(PANEL_BORDER); |
| | | } |
| | | |
| | | /** |
| | | * Updates the contents of the panel. |
| | | * |
| | | */ |
| | | public void updateContents() |
| | | { |
| | | ServerDescriptor server = null; |
| | | if (getInfo() != null) |
| | | { |
| | | server = getInfo().getServerDescriptor(); |
| | | } |
| | | CustomSearchResult csr = null; |
| | | if (server != null) |
| | | { |
| | | csr = server.getRootMonitor(); |
| | | } |
| | | if (csr != null) |
| | | { |
| | | JLabel[] ls = |
| | | { |
| | | openConnections, |
| | | maxConnections, |
| | | totalConnections, |
| | | startTime |
| | | }; |
| | | BasicMonitoringAttributes[] attrs = |
| | | { |
| | | BasicMonitoringAttributes.CURRENT_CONNECTIONS, |
| | | BasicMonitoringAttributes.MAX_CONNECTIONS, |
| | | BasicMonitoringAttributes.TOTAL_CONNECTIONS, |
| | | BasicMonitoringAttributes.START_DATE |
| | | }; |
| | | for (int i=0; i<ls.length; i++) |
| | | { |
| | | ls[i].setText(getMonitoringValue(attrs[i], csr)); |
| | | } |
| | | version.setText(server.getOpenDSVersion()); |
| | | try |
| | | { |
| | | String start = (String)getFirstMonitoringValue(csr, |
| | | BasicMonitoringAttributes.START_DATE.getAttributeName()); |
| | | String current = (String)getFirstMonitoringValue(csr, |
| | | BasicMonitoringAttributes.CURRENT_DATE.getAttributeName()); |
| | | Date startTime = ConfigFromDirContext.utcParser.parse(start); |
| | | Date currentTime = ConfigFromDirContext.utcParser.parse(current); |
| | | |
| | | long upSeconds = (currentTime.getTime() - startTime.getTime()) / 1000; |
| | | long upDays = (upSeconds / 86400); |
| | | upSeconds %= 86400; |
| | | long upHours = (upSeconds / 3600); |
| | | upSeconds %= 3600; |
| | | long upMinutes = (upSeconds / 60); |
| | | upSeconds %= 60; |
| | | Message upTimeStr = |
| | | INFO_MONITOR_UPTIME.get(upDays, upHours, upMinutes, upSeconds); |
| | | |
| | | upTime.setText(upTimeStr.toString()); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | upTime.setText(NO_VALUE_SET.toString()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | openConnections.setText(NO_VALUE_SET.toString()); |
| | | maxConnections.setText(NO_VALUE_SET.toString()); |
| | | totalConnections.setText(NO_VALUE_SET.toString()); |
| | | startTime.setText(NO_VALUE_SET.toString()); |
| | | upTime.setText(NO_VALUE_SET.toString()); |
| | | version.setText(NO_VALUE_SET.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | |
| | | import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.CategorizedComboBoxElement; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | | import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; |
| | | import org.opends.guitools.controlpanel.datamodel.MonitoringAttributes; |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | | import org.opends.guitools.controlpanel.event.*; |
| | | import org.opends.guitools.controlpanel.task.RebuildIndexTask; |
| | |
| | | { |
| | | return ColorAndFontConstants.textAreaBorder; |
| | | } |
| | | |
| | | /** |
| | | * Returns the monitoring value in a String form to be displayed to the user. |
| | | * @param attr the attribute to analyze. |
| | | * @param monitoringEntry the monitoring entry. |
| | | * @return the monitoring value in a String form to be displayed to the user. |
| | | */ |
| | | public static String getMonitoringValue(MonitoringAttributes attr, |
| | | CustomSearchResult monitoringEntry) |
| | | { |
| | | return Utilities.getMonitoringValue(attr, monitoringEntry); |
| | | } |
| | | |
| | | /** |
| | | * Updates the monitoring information writing it to a list of labels. |
| | | * @param monitoringAttrs the monitoring operations whose information we want |
| | | * to update. |
| | | * @param monitoringLabels the monitoring labels to be updated. |
| | | * @param monitoringEntry the monitoring entry containing the information to |
| | | * be displayed. |
| | | */ |
| | | protected void updateMonitoringInfo( |
| | | List<MonitoringAttributes> monitoringAttrs, |
| | | List<JLabel> monitoringLabels, CustomSearchResult monitoringEntry) |
| | | { |
| | | for (int i=0 ; i<monitoringAttrs.size(); i++) |
| | | { |
| | | String value = |
| | | getMonitoringValue(monitoringAttrs.get(i), monitoringEntry); |
| | | JLabel l = monitoringLabels.get(i); |
| | | l.setText(value); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns the first value for a given attribute in the provided entry. |
| | | * @param sr the entry. It may be <CODE>null</CODE>. |
| | | * @param attrName the attribute name. |
| | | * @return the first value for a given attribute in the provided entry. |
| | | */ |
| | | protected Object getFirstMonitoringValue(CustomSearchResult sr, |
| | | String attrName) |
| | | { |
| | | return Utilities.getFirstMonitoringValue(sr, attrName); |
| | | } |
| | | |
| | | /** |
| | | * Returns the label to be used in panels (with ':') based on the definition |
| | | * of the monitoring attribute. |
| | | * @param attr the monitoring attribute. |
| | | * @return the label to be used in panels (with ':') based on the definition |
| | | * of the monitoring attribute. |
| | | */ |
| | | protected static Message getLabel(MonitoringAttributes attr) |
| | | { |
| | | return INFO_CTRL_PANEL_OPERATION_NAME_AS_LABEL.get( |
| | | attr.getMessage().toString()); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import javax.swing.Box; |
| | | import javax.swing.JLabel; |
| | | |
| | | import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; |
| | | import org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes; |
| | | import org.opends.guitools.controlpanel.datamodel.MonitoringAttributes; |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | |
| | | /** |
| | | * The panel displaying the system information monitoring panel. |
| | | */ |
| | | public class SystemInformationMonitoringPanel extends GeneralMonitoringPanel |
| | | { |
| | | private static final long serialVersionUID = 9031734563298069830L; |
| | | static List<MonitoringAttributes> operations = |
| | | new ArrayList<MonitoringAttributes>(); |
| | | { |
| | | operations.add(BasicMonitoringAttributes.SYSTEM_NAME); |
| | | operations.add(BasicMonitoringAttributes.OPERATING_SYSTEM); |
| | | operations.add(BasicMonitoringAttributes.AVAILABLE_CPUS); |
| | | operations.add(BasicMonitoringAttributes.USED_MEMORY); |
| | | operations.add(BasicMonitoringAttributes.FREE_USED_MEMORY); |
| | | operations.add(BasicMonitoringAttributes.MAX_MEMORY); |
| | | } |
| | | private ArrayList<JLabel> monitoringLabels = |
| | | new ArrayList<JLabel>(); |
| | | { |
| | | for (int i=0; i<operations.size(); i++) |
| | | { |
| | | monitoringLabels.add(Utilities.createDefaultLabel()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Default constructor. |
| | | */ |
| | | public SystemInformationMonitoringPanel() |
| | | { |
| | | super(); |
| | | createLayout(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Component getPreferredFocusComponent() |
| | | { |
| | | return monitoringLabels.get(0); |
| | | } |
| | | |
| | | /** |
| | | * Creates the layout of the panel (but the contents are not populated here). |
| | | */ |
| | | private void createLayout() |
| | | { |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | JLabel lTitle = Utilities.createTitleLabel( |
| | | INFO_CTRL_PANEL_SYSTEM_INFORMATION.get()); |
| | | gbc.fill = GridBagConstraints.NONE; |
| | | gbc.anchor = GridBagConstraints.WEST; |
| | | gbc.gridwidth = 2; |
| | | gbc.gridx = 0; |
| | | gbc.gridy = 0; |
| | | gbc.insets.top = 5; |
| | | gbc.insets.bottom = 7; |
| | | add(lTitle, gbc); |
| | | |
| | | gbc.insets.bottom = 0; |
| | | gbc.insets.top = 10; |
| | | gbc.gridy ++; |
| | | gbc.anchor = GridBagConstraints.WEST; |
| | | gbc.gridwidth = 1; |
| | | for (int i=0; i<operations.size(); i++) |
| | | { |
| | | JLabel l = Utilities.createPrimaryLabel(getLabel(operations.get(i))); |
| | | gbc.gridy ++; |
| | | gbc.insets.left = 0; |
| | | gbc.gridx = 0; |
| | | gbc.weightx = 0.0; |
| | | gbc.gridwidth = 1; |
| | | add(l, gbc); |
| | | gbc.insets.left = 10; |
| | | gbc.gridx = 1; |
| | | gbc.gridwidth = 2; |
| | | add(monitoringLabels.get(i), gbc); |
| | | } |
| | | |
| | | gbc.gridx = 0; |
| | | gbc.gridy ++; |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | gbc.weightx = 1.0; |
| | | gbc.weighty = 1.0; |
| | | gbc.gridwidth = 3; |
| | | add(Box.createGlue(), gbc); |
| | | |
| | | setBorder(PANEL_BORDER); |
| | | } |
| | | |
| | | /** |
| | | * Updates the contents of the panel. |
| | | * |
| | | */ |
| | | public void updateContents() |
| | | { |
| | | ServerDescriptor server = null; |
| | | if (getInfo() != null) |
| | | { |
| | | server = getInfo().getServerDescriptor(); |
| | | } |
| | | CustomSearchResult csr = null; |
| | | if (server != null) |
| | | { |
| | | csr = server.getSystemInformationMonitor(); |
| | | } |
| | | if (csr != null) |
| | | { |
| | | updateMonitoringInfo(operations, monitoringLabels, csr); |
| | | } |
| | | else |
| | | { |
| | | for (JLabel l : monitoringLabels) |
| | | { |
| | | l.setText(NO_VALUE_SET.toString()); |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import javax.swing.Box; |
| | | import javax.swing.JLabel; |
| | | |
| | | import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; |
| | | import org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes; |
| | | import org.opends.guitools.controlpanel.datamodel.MonitoringAttributes; |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | |
| | | /** |
| | | * The panel displaying the work queue monitor panel. |
| | | */ |
| | | public class WorkQueueMonitoringPanel extends GeneralMonitoringPanel |
| | | { |
| | | private static final long serialVersionUID = 9031734563700069830L; |
| | | static List<MonitoringAttributes> attributes = |
| | | new ArrayList<MonitoringAttributes>(); |
| | | { |
| | | attributes.add(BasicMonitoringAttributes.AVERAGE_REQUEST_BACKLOG); |
| | | attributes.add(BasicMonitoringAttributes.MAX_REQUEST_BACKLOG); |
| | | attributes.add(BasicMonitoringAttributes.CURRENT_REQUEST_BACKLOG); |
| | | attributes.add(BasicMonitoringAttributes.REQUESTS_SUBMITTED); |
| | | attributes.add(BasicMonitoringAttributes.REQUESTS_REJECTED); |
| | | } |
| | | private ArrayList<JLabel> monitoringLabels = |
| | | new ArrayList<JLabel>(); |
| | | { |
| | | for (int i=0; i<attributes.size(); i++) |
| | | { |
| | | monitoringLabels.add(Utilities.createDefaultLabel()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Default constructor. |
| | | */ |
| | | public WorkQueueMonitoringPanel() |
| | | { |
| | | super(); |
| | | createLayout(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Component getPreferredFocusComponent() |
| | | { |
| | | return monitoringLabels.get(0); |
| | | } |
| | | |
| | | /** |
| | | * Creates the layout of the panel (but the contents are not populated here). |
| | | */ |
| | | private void createLayout() |
| | | { |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | JLabel lTitle = Utilities.createTitleLabel( |
| | | INFO_CTRL_PANEL_WORK_QUEUE.get()); |
| | | gbc.fill = GridBagConstraints.NONE; |
| | | gbc.anchor = GridBagConstraints.WEST; |
| | | gbc.gridwidth = 2; |
| | | gbc.gridx = 0; |
| | | gbc.gridy = 0; |
| | | gbc.insets.top = 5; |
| | | gbc.insets.bottom = 7; |
| | | add(lTitle, gbc); |
| | | |
| | | gbc.insets.bottom = 0; |
| | | gbc.insets.top = 10; |
| | | gbc.gridy ++; |
| | | gbc.anchor = GridBagConstraints.WEST; |
| | | gbc.gridwidth = 1; |
| | | for (int i=0; i<attributes.size(); i++) |
| | | { |
| | | JLabel l = Utilities.createPrimaryLabel(getLabel(attributes.get(i))); |
| | | gbc.gridy ++; |
| | | gbc.insets.left = 0; |
| | | gbc.gridx = 0; |
| | | gbc.weightx = 0.0; |
| | | gbc.gridwidth = 1; |
| | | add(l, gbc); |
| | | gbc.insets.left = 10; |
| | | gbc.gridx = 1; |
| | | gbc.gridwidth = 2; |
| | | add(monitoringLabels.get(i), gbc); |
| | | } |
| | | |
| | | gbc.gridx = 0; |
| | | gbc.gridy ++; |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | gbc.weightx = 1.0; |
| | | gbc.weighty = 1.0; |
| | | gbc.gridwidth = 3; |
| | | add(Box.createGlue(), gbc); |
| | | |
| | | setBorder(PANEL_BORDER); |
| | | } |
| | | |
| | | /** |
| | | * Updates the contents of the panel. |
| | | * |
| | | */ |
| | | public void updateContents() |
| | | { |
| | | ServerDescriptor server = null; |
| | | if (getInfo() != null) |
| | | { |
| | | server = getInfo().getServerDescriptor(); |
| | | } |
| | | CustomSearchResult csr = null; |
| | | if (server != null) |
| | | { |
| | | csr = server.getWorkQueueMonitor(); |
| | | } |
| | | if (csr != null) |
| | | { |
| | | updateMonitoringInfo(attributes, monitoringLabels, csr); |
| | | } |
| | | else |
| | | { |
| | | for (JLabel l : monitoringLabels) |
| | | { |
| | | l.setText(NO_VALUE_SET.toString()); |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui.nodes; |
| | | |
| | | import javax.swing.tree.DefaultMutableTreeNode; |
| | | |
| | | /** |
| | | * Abstract class with some common methods for all the nodes in the |
| | | * 'General Information' tree. |
| | | * |
| | | */ |
| | | public class GeneralMonitoringTreeNode extends DefaultMutableTreeNode |
| | | { |
| | | private static final long serialVersionUID = 7896765876669863639L; |
| | | private String displayName; |
| | | private Object identifier; |
| | | private boolean isRoot; |
| | | |
| | | /** |
| | | * Constructor of the node. |
| | | * @param displayName the name of the node. |
| | | * @param identifier the identifier that is unique among all the nodes. |
| | | * @param isRoot whether the node is the root or not. |
| | | */ |
| | | public GeneralMonitoringTreeNode(String displayName, |
| | | Object identifier, |
| | | boolean isRoot) |
| | | { |
| | | super(displayName); |
| | | this.displayName = displayName; |
| | | this.identifier = identifier; |
| | | this.isRoot = isRoot; |
| | | } |
| | | |
| | | /** |
| | | * Returns the name of the node. |
| | | * @return the name of the node. |
| | | */ |
| | | public String getDisplayName() |
| | | { |
| | | return displayName; |
| | | } |
| | | |
| | | /** |
| | | * Returns the identifier that is unique among all the nodes. |
| | | * @return the identifier that is unique among all the nodes. |
| | | */ |
| | | public Object getIdentifier() |
| | | { |
| | | return identifier; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isRoot() |
| | | { |
| | | return isRoot; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isLeaf() |
| | | { |
| | | return getChildCount() == 0; |
| | | } |
| | | } |
| | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | |
| | | import java.net.InetAddress; |
| | | import java.text.DateFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.SortedSet; |
| | | import java.util.TimeZone; |
| | | import java.util.TreeSet; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | |
| | | import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn.IndexType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.OpenDsException; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | /** |
| | | * A class that reads the configuration and monitoring information using a |
| | |
| | | private static final Logger LOG = |
| | | Logger.getLogger(ConfigFromDirContext.class.getName()); |
| | | |
| | | private CustomSearchResult rootMonitor; |
| | | private CustomSearchResult jvmMemoryUsage; |
| | | private CustomSearchResult systemInformation; |
| | | private CustomSearchResult entryCaches; |
| | | private CustomSearchResult workQueue; |
| | | |
| | | private Map<String, CustomSearchResult> hmConnectionHandlersMonitor = |
| | | new HashMap<String, CustomSearchResult>(); |
| | | |
| | | /** |
| | | * The monitor root entry DN. |
| | | */ |
| | | protected DN monitorDN = DN.nullDN(); |
| | | /** |
| | | * The JVM memory usage monitoring entry DN. |
| | | */ |
| | | protected DN jvmMemoryUsageDN = DN.nullDN(); |
| | | /** |
| | | * The system information monitoring entry DN. |
| | | */ |
| | | protected DN systemInformationDN = DN.nullDN(); |
| | | /** |
| | | * The entry cache monitoring entry DN. |
| | | */ |
| | | protected DN entryCachesDN = DN.nullDN(); |
| | | /** |
| | | * The work queue monitoring entry DN. |
| | | */ |
| | | protected DN workQueueDN = DN.nullDN(); |
| | | |
| | | { |
| | | try |
| | | { |
| | | monitorDN = DN.decode("cn=monitor"); |
| | | jvmMemoryUsageDN = DN.decode("cn=JVM Memory Usage,cn=monitor"); |
| | | systemInformationDN = DN.decode("cn=System Information,cn=monitor"); |
| | | entryCachesDN = DN.decode("cn=Entry Caches,cn=monitor"); |
| | | workQueueDN = DN.decode("cn=Work Queue,cn=monitor"); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | throw new IllegalStateException("Could not decode DNs: "+t, t); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * The date formatter to be used to parse GMT dates. |
| | | */ |
| | | public static final SimpleDateFormat utcParser = new SimpleDateFormat( |
| | | ServerConstants.DATE_FORMAT_GMT_TIME); |
| | | { |
| | | utcParser.setTimeZone(TimeZone.getTimeZone("UTC")); |
| | | } |
| | | /** |
| | | * The date formatter to be used to format dates. |
| | | */ |
| | | public static final DateFormat formatter = DateFormat.getDateTimeInstance(); |
| | | |
| | | /** |
| | | * Returns the monitoring entry for the entry caches. |
| | | * @return the monitoring entry for the entry caches. |
| | | */ |
| | | public CustomSearchResult getEntryCaches() |
| | | { |
| | | return entryCaches; |
| | | } |
| | | |
| | | /** |
| | | * Returns the monitoring entry for the JVM memory usage. |
| | | * @return the monitoring entry for the JVM memory usage. |
| | | */ |
| | | public CustomSearchResult getJvmMemoryUsage() |
| | | { |
| | | return jvmMemoryUsage; |
| | | } |
| | | |
| | | /** |
| | | * Returns the root entry of the monitoring tree. |
| | | * @return the root entry of the monitoring tree. |
| | | */ |
| | | public CustomSearchResult getRootMonitor() |
| | | { |
| | | return rootMonitor; |
| | | } |
| | | |
| | | /** |
| | | * Returns the monitoring entry for the system information. |
| | | * @return the monitoring entry for the system information. |
| | | */ |
| | | public CustomSearchResult getSystemInformation() |
| | | { |
| | | return systemInformation; |
| | | } |
| | | |
| | | /** |
| | | * Returns the monitoring entry for the work queue. |
| | | * @return the monitoring entry for the work queue. |
| | | */ |
| | | public CustomSearchResult getWorkQueue() |
| | | { |
| | | return workQueue; |
| | | } |
| | | |
| | | /** |
| | | * Reads configuration and monitoring information using the provided |
| | | * connection. |
| | |
| | | Set<BackendDescriptor> bs = new HashSet<BackendDescriptor>(); |
| | | Set<DN> as = new HashSet<DN>(); |
| | | |
| | | rootMonitor = null; |
| | | jvmMemoryUsage = null; |
| | | systemInformation = null; |
| | | entryCaches = null; |
| | | workQueue = null; |
| | | |
| | | hmConnectionHandlersMonitor.clear(); |
| | | |
| | | try |
| | | { |
| | | // Get the Directory Server configuration handler and use it. |
| | |
| | | isReplicationSecure ? |
| | | ConnectionHandlerDescriptor.Protocol.REPLICATION_SECURE : |
| | | ConnectionHandlerDescriptor.Protocol.REPLICATION; |
| | | Set<CustomSearchResult> emptySet = Collections.emptySet(); |
| | | ConnectionHandlerDescriptor connHandler = |
| | | new ConnectionHandlerDescriptor( |
| | | new HashSet<InetAddress>(), |
| | | replicationPort, |
| | | protocol, |
| | | ConnectionHandlerDescriptor.State.ENABLED, |
| | | "Multimaster Synchronization"); |
| | | "Multimaster Synchronization", |
| | | emptySet); |
| | | ls.add(connHandler); |
| | | } |
| | | } |
| | |
| | | ERR_READING_CONFIG_LDAP.get(t.toString()), t); |
| | | ex.add(oupe); |
| | | } |
| | | for (ConnectionHandlerDescriptor ch : getConnectionHandlers()) |
| | | { |
| | | ch.setMonitoringEntries(getMonitoringEntries(ch)); |
| | | } |
| | | if (adminConnector != null) |
| | | { |
| | | adminConnector.setMonitoringEntries(getMonitoringEntries(adminConnector)); |
| | | } |
| | | exceptions = Collections.unmodifiableList(ex); |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | protected String[] getMonitoringAttributes() |
| | | { |
| | | return new String[] { |
| | | "approx-older-change-not-synchronized-millis", "missing-changes", |
| | | "base-dn", "server-id", "javaVersion", "currentConnections", |
| | | "ds-backend-id", "ds-backend-entry-count", "ds-base-dn-entry-count" |
| | | "*" |
| | | }; |
| | | } |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | CustomSearchResult csr = new CustomSearchResult(sr, searchBaseDN); |
| | | String backendID = ConnectionUtils.getFirstValue(sr, |
| | | "ds-backend-id"); |
| | | String entryCount = ConnectionUtils.getFirstValue(sr, |
| | |
| | | { |
| | | if (backend.getBackendID().equalsIgnoreCase(monitorBackendID)) |
| | | { |
| | | CustomSearchResult csr = new CustomSearchResult(sr, searchBaseDN); |
| | | backend.setMonitoringEntry(csr); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | try |
| | | { |
| | | if ((rootMonitor == null) && isRootMonitor(csr)) |
| | | { |
| | | rootMonitor = csr; |
| | | } |
| | | else if ((entryCaches == null) && isEntryCaches(csr)) |
| | | { |
| | | entryCaches = csr; |
| | | } |
| | | else if ((workQueue == null) && isWorkQueue(csr)) |
| | | { |
| | | workQueue = csr; |
| | | } |
| | | else if ((jvmMemoryUsage == null) && isJvmMemoryUsage(csr)) |
| | | { |
| | | jvmMemoryUsage = csr; |
| | | } |
| | | else if ((systemInformation == null) && isSystemInformation(csr)) |
| | | { |
| | | systemInformation = csr; |
| | | } |
| | | else if (isConnectionHandler(csr)) |
| | | { |
| | | String statistics = " Statistics"; |
| | | String cn = ConnectionUtils.getFirstValue(sr, "cn"); |
| | | if (cn.endsWith(statistics)) |
| | | { |
| | | // Assume it is a connection handler |
| | | String name = cn.substring(0, cn.length() - statistics.length()); |
| | | hmConnectionHandlersMonitor.put(getKey(name), csr); |
| | | } |
| | | } |
| | | } |
| | | catch (OpenDsException ode) |
| | | { |
| | | exceptions.add(ode); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | protocol = ConnectionHandlerDescriptor.Protocol.OTHER; |
| | | port = -1; |
| | | } |
| | | Set<CustomSearchResult> emptySet = Collections.emptySet(); |
| | | return new ConnectionHandlerDescriptor(addresses, port, protocol, state, |
| | | name); |
| | | name, emptySet); |
| | | } |
| | | |
| | | private ConnectionHandlerDescriptor getConnectionHandler( |
| | |
| | | } |
| | | int port = adminConnector.getListenPort(); |
| | | |
| | | Set<CustomSearchResult> emptySet = Collections.emptySet(); |
| | | return new ConnectionHandlerDescriptor(addresses, port, protocol, state, |
| | | INFO_CTRL_PANEL_CONN_HANDLER_ADMINISTRATION.get().toString()); |
| | | INFO_CTRL_PANEL_CONN_HANDLER_ADMINISTRATION.get().toString(), emptySet); |
| | | } |
| | | |
| | | private boolean isRootMonitor(CustomSearchResult csr) |
| | | throws OpenDsException |
| | | { |
| | | return monitorDN.equals(DN.decode(csr.getDN())); |
| | | } |
| | | |
| | | private boolean isSystemInformation(CustomSearchResult csr) |
| | | throws OpenDsException |
| | | { |
| | | return systemInformationDN.equals(DN.decode(csr.getDN())); |
| | | } |
| | | |
| | | private boolean isJvmMemoryUsage(CustomSearchResult csr) |
| | | throws OpenDsException |
| | | { |
| | | return jvmMemoryUsageDN.equals(DN.decode(csr.getDN())); |
| | | } |
| | | |
| | | private boolean isWorkQueue(CustomSearchResult csr) |
| | | throws OpenDsException |
| | | { |
| | | return workQueueDN.equals(DN.decode(csr.getDN())); |
| | | } |
| | | |
| | | private boolean isEntryCaches(CustomSearchResult csr) |
| | | throws OpenDsException |
| | | { |
| | | return entryCachesDN.equals(DN.decode(csr.getDN())); |
| | | } |
| | | |
| | | private boolean isConnectionHandler(CustomSearchResult csr) |
| | | throws OpenDsException |
| | | { |
| | | boolean isConnectionHandler = false; |
| | | DN dn = DN.decode(csr.getDN()); |
| | | DN parent = dn.getParent(); |
| | | if ((parent != null) && parent.equals(monitorDN)) |
| | | { |
| | | Set vs = csr.getAttributeValues("cn"); |
| | | if ((vs != null) && !vs.isEmpty()) |
| | | { |
| | | String cn = (String)vs.iterator().next(); |
| | | String statistics = " Statistics"; |
| | | if (cn.endsWith(statistics)) |
| | | { |
| | | isConnectionHandler = true; |
| | | } |
| | | } |
| | | } |
| | | return isConnectionHandler; |
| | | } |
| | | |
| | | /** |
| | | * Commodity method to get the string representation to be used in the |
| | | * hash maps as key. |
| | | * @param value the value to be transformed into a key for a hash map. |
| | | * @return the string representation to be used in the hash maps as key. |
| | | */ |
| | | private String getKey(String value) |
| | | { |
| | | return value.toLowerCase(); |
| | | } |
| | | |
| | | private Set<CustomSearchResult>getMonitoringEntries( |
| | | ConnectionHandlerDescriptor ch) |
| | | { |
| | | Set<CustomSearchResult> monitorEntries = new HashSet<CustomSearchResult>(); |
| | | for (String key : hmConnectionHandlersMonitor.keySet()) |
| | | { |
| | | if (key.indexOf(getKey(ch.getName())) != -1) |
| | | { |
| | | monitorEntries.add(hmConnectionHandlersMonitor.get(key)); |
| | | } |
| | | } |
| | | |
| | | return monitorEntries; |
| | | } |
| | | } |
| | |
| | | import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; |
| | | import org.opends.guitools.controlpanel.datamodel.IndexDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.VLVIndexDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.VLVSortOrder; |
| | |
| | | isReplicationSecure ? |
| | | ConnectionHandlerDescriptor.Protocol.REPLICATION_SECURE : |
| | | ConnectionHandlerDescriptor.Protocol.REPLICATION; |
| | | Set<CustomSearchResult> emptySet = Collections.emptySet(); |
| | | ConnectionHandlerDescriptor connHandler = |
| | | new ConnectionHandlerDescriptor( |
| | | new HashSet<InetAddress>(), |
| | | replicationPort, |
| | | protocol, |
| | | ConnectionHandlerDescriptor.State.ENABLED, |
| | | "Multimaster Synchronization"); |
| | | "Multimaster Synchronization", |
| | | emptySet); |
| | | ls.add(connHandler); |
| | | } |
| | | } |
| | |
| | | protocol = ConnectionHandlerDescriptor.Protocol.OTHER; |
| | | port = -1; |
| | | } |
| | | Set<CustomSearchResult> emptySet = Collections.emptySet(); |
| | | return new ConnectionHandlerDescriptor(addresses, port, protocol, state, |
| | | name); |
| | | name, emptySet); |
| | | } |
| | | |
| | | private ConnectionHandlerDescriptor getConnectionHandler( |
| | |
| | | addresses.addAll(v); |
| | | } |
| | | int port = adminConnector.getListenPort(); |
| | | |
| | | Set<CustomSearchResult> emptySet = Collections.emptySet(); |
| | | return new ConnectionHandlerDescriptor(addresses, port, protocol, state, |
| | | INFO_CTRL_PANEL_CONN_HANDLER_ADMINISTRATION.get().toString()); |
| | | INFO_CTRL_PANEL_CONN_HANDLER_ADMINISTRATION.get().toString(), |
| | | emptySet); |
| | | } |
| | | } |
| | |
| | | import java.text.StringCharacterIterator; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Date; |
| | | import java.util.Set; |
| | | |
| | | import javax.naming.CompositeName; |
| | | import javax.naming.InvalidNameException; |
| | |
| | | import org.opends.guitools.controlpanel.browser.IconPool; |
| | | import org.opends.guitools.controlpanel.datamodel.ConfigReadException; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | | import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; |
| | | import org.opends.guitools.controlpanel.datamodel.MonitoringAttributes; |
| | | import org.opends.guitools.controlpanel.datamodel.SortableTableModel; |
| | | import org.opends.guitools.controlpanel.datamodel.VLVIndexDescriptor; |
| | | import org.opends.guitools.controlpanel.event.TextComponentFocusListener; |
| | |
| | | |
| | | private static ImageIcon requiredIcon; |
| | | |
| | | |
| | | private static Message NO_VALUE_SET = |
| | | INFO_CTRL_PANEL_NO_MONITORING_VALUE.get(); |
| | | private static Message NOT_IMPLEMENTED = |
| | | INFO_CTRL_PANEL_NOT_IMPLEMENTED.get(); |
| | | |
| | | /** |
| | | * Returns <CODE>true</CODE> if we are running Mac OS and <CODE>false</CODE> |
| | | * otherwise. |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the first value for a given attribute in the provided entry. |
| | | * @param sr the entry. It may be <CODE>null</CODE>. |
| | | * @param attrName the attribute name. |
| | | * @return the first value for a given attribute in the provided entry. |
| | | */ |
| | | public static Object getFirstMonitoringValue(CustomSearchResult sr, |
| | | String attrName) |
| | | { |
| | | Object o = null; |
| | | if (sr != null) |
| | | { |
| | | Set<Object> values = sr.getAttributeValues(attrName); |
| | | if ((values != null) && (values.size() > 0)) |
| | | { |
| | | o = values.iterator().next(); |
| | | try |
| | | { |
| | | Long l = Long.parseLong(o.toString()); |
| | | o = l; |
| | | } |
| | | catch (Throwable t1) |
| | | { |
| | | try |
| | | { |
| | | Double d = Double.parseDouble(o.toString()); |
| | | o = d; |
| | | } |
| | | catch (Throwable t2) |
| | | { |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return o; |
| | | } |
| | | |
| | | /** |
| | | * Returns the monitoring value in a String form to be displayed to the user. |
| | | * @param attr the attribute to analyze. |
| | | * @param monitoringEntry the monitoring entry. |
| | | * @return the monitoring value in a String form to be displayed to the user. |
| | | */ |
| | | public static String getMonitoringValue(MonitoringAttributes attr, |
| | | CustomSearchResult monitoringEntry) |
| | | { |
| | | String returnValue; |
| | | Object monitoringValue = |
| | | Utilities.getFirstMonitoringValue(monitoringEntry, |
| | | attr.getAttributeName()); |
| | | if (monitoringValue == null) |
| | | { |
| | | returnValue = NO_VALUE_SET.toString(); |
| | | } |
| | | else if (isNotImplemented(attr, monitoringEntry)) |
| | | { |
| | | returnValue = NOT_IMPLEMENTED.toString(); |
| | | } |
| | | else if (attr.isNumericDate()) |
| | | { |
| | | if("0".equals(monitoringValue.toString())) |
| | | { |
| | | returnValue = NO_VALUE_SET.toString(); |
| | | } |
| | | else |
| | | { |
| | | Long l = Long.parseLong(monitoringValue.toString()); |
| | | Date date = new Date(l); |
| | | returnValue = ConfigFromDirContext.formatter.format(date); |
| | | } |
| | | } |
| | | else if (attr.isTime()) |
| | | { |
| | | if("-1".equals(monitoringValue.toString())) |
| | | { |
| | | returnValue = NO_VALUE_SET.toString(); |
| | | } |
| | | else |
| | | { |
| | | returnValue = monitoringValue.toString(); |
| | | } |
| | | } |
| | | else if (attr.isGMTDate()) |
| | | { |
| | | try |
| | | { |
| | | Date date = ConfigFromDirContext.utcParser.parse( |
| | | monitoringValue.toString()); |
| | | returnValue = ConfigFromDirContext.formatter.format(date); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | returnValue = monitoringValue.toString(); |
| | | } |
| | | } |
| | | else if (attr.isValueInBytes()) |
| | | { |
| | | Long l = Long.parseLong(monitoringValue.toString()); |
| | | long mb = l / (1024 * 1024); |
| | | long kbs = (l - (mb * 1024 * 1024)) / 1024; |
| | | returnValue = INFO_CTRL_PANEL_MEMORY_VALUE.get(mb , kbs).toString(); |
| | | } |
| | | else |
| | | { |
| | | returnValue = monitoringValue.toString(); |
| | | } |
| | | return returnValue; |
| | | } |
| | | |
| | | /** |
| | | * Returns <CODE>true</CODE> if the provided monitoring value represents the |
| | | * non implemented label and <CODE>false</CODE> otherwise. |
| | | * @param attr the attribute to analyze. |
| | | * @param monitoringEntry the monitoring entry. |
| | | * @return <CODE>true</CODE> if the provided monitoring value represents the |
| | | * non implemented label and <CODE>false</CODE> otherwise. |
| | | */ |
| | | public static boolean isNotImplemented(MonitoringAttributes attr, |
| | | CustomSearchResult monitoringEntry) |
| | | { |
| | | boolean returnValue; |
| | | Object monitoringValue = Utilities.getFirstMonitoringValue( |
| | | monitoringEntry, |
| | | attr.getAttributeName()); |
| | | if (attr.isNumeric() && (monitoringValue != null)) |
| | | { |
| | | try |
| | | { |
| | | Long.parseLong(String.valueOf(monitoringValue)); |
| | | returnValue = false; |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | returnValue = true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | returnValue = false; |
| | | } |
| | | return returnValue; |
| | | } |
| | | } |
| | |
| | | INFO_CTRL_PANEL_REFRESH_OPTIONS_LABEL=Refresh Period (sec): |
| | | INFO_CTRL_PANEL_INVALID_PERIOD_VALUE=The period time must be an integer \ |
| | | positive value smaller than %d seconds. |
| | | |
| | | INFO_CTRL_PANEL_CATEGORY_MONITORING=Monitoring |
| | | INFO_CTRL_PANEL_BROWSE_GENERAL_MONITORING=General Information |
| | | INFO_CTRL_PANEL_GENERAL_MONITORING_NO_ITEM_SELECTED=-No Item Selected- |
| | | INFO_CTRL_PANEL_MULTIPLE_ITEMS_SELECTED=-Multiple Items Selected- |
| | | INFO_CTRL_PANEL_GENERAL_MONITORING_TITLE=General Information |
| | | INFO_CTRL_PANEL_AUTH_REQUIRED_TO_BROWSE_MONITORING_SUMMARY=The server is \ |
| | | running. You must provide authentication to see the monitoring data. |
| | | INFO_CTRL_PANEL_SERVER_MUST_RUN_TO_BROWSE_MONITORING_SUMMARY=To see the \ |
| | | monitoring data the server must be running and you must provide \ |
| | | authentication. |
| | | INFO_CTRL_PANEL_GENERAL_MONITORING_ROOT_TREE_NODE=ds-directory.png |
| | | INFO_CTRL_PANEL_SYSTEM_INFORMATION_TREE_NODE=ds-generic.png |
| | | INFO_CTRL_PANEL_JVM_MEMORY_USAGE_TREE_NODE=ds-generic.png |
| | | INFO_CTRL_PANEL_WORK_QUEUE_TREE_NODE=ds-generic.png |
| | | INFO_CTRL_PANEL_ENTRY_CACHES_TREE_NODE=ds-generic.png |
| | | INFO_CTRL_PANEL_DB_ENVIRONMENT_TREE_NODE=ds-suffix.png |
| | | INFO_CTRL_PANEL_GENERAL_MONITORING_ROOT=Monitoring Root |
| | | INFO_CTRL_PANEL_SYSTEM_INFORMATION=System Information |
| | | INFO_CTRL_PANEL_JAVA_INFORMATION=Java Information |
| | | INFO_CTRL_PANEL_WORK_QUEUE=Work Queue |
| | | INFO_CTRL_PANEL_ENTRY_CACHES=Entry Cache |
| | | INFO_CTRL_PANEL_DB_ENVIRONMENT=Database Environment |
| | | INFO_CTRL_PANEL_UP_TIME_LABEL=Up Time: |
| | | INFO_CTRL_PANEL_MAX_CONNECTIONS_LABEL=Max Connections: |
| | | INFO_CTRL_PANEL_TOTAL_CONNECTIONS_LABEL=Total Connections: |
| | | INFO_CTRL_PANEL_START_TIME_LABEL=Start Time: |
| | | INFO_CTRL_PANEL_AVERAGE_REQUEST_BACKLOG=Average Request Backlog |
| | | INFO_CTRL_PANEL_MAX_REQUEST_BACKLOG=Maximum Request Backlog |
| | | INFO_CTRL_PANEL_CURRENT_REQUEST_BACKLOG=Current Request Backlog |
| | | INFO_CTRL_PANEL_REQUESTS_SUBMITTED=Requests Submitted |
| | | INFO_CTRL_PANEL_REQUESTS_REJECTED=Requests Rejected Due To Full Queue |
| | | INFO_CTRL_PANEL_ENTRY_CACHE_HITS=Entry Cache Hits |
| | | INFO_CTRL_PANEL_CURRENT_ENTRY_CACHE_COUNT=Entry Cache Count |
| | | INFO_CTRL_PANEL_ENTRY_CACHE_TRIES=Entry Cache Tries |
| | | INFO_CTRL_PANEL_ENTRY_CACHE_HIT_RATIO=Entry Cache Hit Ratio |
| | | INFO_CTRL_PANEL_CURRENT_ENTRY_CACHE_SIZE=Entry Cache Size |
| | | INFO_CTRL_PANEL_MAX_ENTRY_CACHE_SIZE=Max Entry Cache Size |
| | | INFO_CTRL_PANEL_MAX_ENTRY_CACHE_COUNT=Max Entry Cache Count |
| | | INFO_CTRL_PANEL_NO_DBS_FOUND=-No Databases Found- |
| | | INFO_CTRL_PANEL_DB_HEADER=Backend ID |
| | | INFO_CTRL_PANEL_NO_DB_MONITORING_FOUND=-No Database Environment Data \ |
| | | Found- |
| | | INFO_CTRL_PANEL_AVAILABLE_CPUS=Available CPUs |
| | | INFO_CTRL_PANEL_SYSTEM_NAME=System Name |
| | | INFO_CTRL_PANEL_OPERATING_SYSTEM=Operating System |
| | | INFO_CTRL_PANEL_FREE_USED_MEMORY=Free Used Memory |
| | | INFO_CTRL_PANEL_MAX_MEMORY=Max Memory |
| | | INFO_CTRL_PANEL_USED_MEMORY=Used Memory |
| | | INFO_CTRL_PANEL_CLASS_PATH=Class Path |
| | | INFO_CTRL_PANEL_JAVA_VENDOR=Java Vendor |
| | | INFO_CTRL_PANEL_JVM_VENDOR=JVM Vendor |
| | | INFO_CTRL_PANEL_JAVA_VERSION=Java Version |
| | | INFO_CTRL_PANEL_JVM_VERSION=JVM Version |
| | | INFO_CTRL_PANEL_JVM_ARCHITECTURE=JVM Architecture |
| | | INFO_CTRL_PANEL_JVM_ARGUMENTS=JVM Arguments |
| | | INFO_CTRL_PANEL_MEMORY_VALUE=%d Mb, %d Kb |
| | | INFO_CTRL_PANEL_EXTRA_JAVA_ATTRIBUTES=Other Attributes |
| | | INFO_CTRL_PANEL_JAVA_MEMORY_ATTRIBUTES=Memory Attributes |
| | | INFO_CTRL_PANEL_NOT_IMPLEMENTED=Not Implemented |
| | | INFO_CTRL_PANEL_NO_MONITORING_VALUE=- |
| | | INFO_CTRL_PANEL_TOTAL_LABEL=TOTAL |
| | | INFO_CTRL_PANEL_ATTRIBUTE_VIEW_OPTIONS_TITLE=Attribute View Options |
| | | INFO_CTRL_PANEL_NO_OPERATION_SELECTED=You must select at least one \ |
| | | operation. |
| | | INFO_CTRL_PANEL_OPERATION_VIEW_LABEL=Show Columns |
| | | INFO_CTRL_PANEL_OPERATIONS_VIEW=Show Operations... |
| | | INFO_CTRL_PANEL_OPERATION_NAME_AS_LABEL=%s: |
| | | INFO_CTRL_PANEL_ADD_REQUESTS_LABEL=Add Requests |
| | | INFO_CTRL_PANEL_ADD_RESPONSES_LABEL=Add Responses |
| | | INFO_CTRL_PANEL_BIND_REQUESTS_LABEL=Bind Requests |
| | | INFO_CTRL_PANEL_BIND_RESPONSES_LABEL=Bind Responses |
| | | INFO_CTRL_PANEL_COMPARE_REQUESTS_LABEL=Compare Requests |
| | | INFO_CTRL_PANEL_COMPARE_RESPONSES_LABEL=Compare Responses |
| | | INFO_CTRL_PANEL_DELETE_REQUESTS_LABEL=Delete Requests |
| | | INFO_CTRL_PANEL_DELETE_RESPONSES_LABEL=Delete Responses |
| | | INFO_CTRL_PANEL_EXTENDED_REQUESTS_LABEL=Extended Requests |
| | | INFO_CTRL_PANEL_EXTENDED_RESPONSES_LABEL=Extended Responses |
| | | INFO_CTRL_PANEL_MOD_DN_REQUESTS_LABEL=Mod DN Requests |
| | | INFO_CTRL_PANEL_MOD_DN_RESPONSES_LABEL=Mod DN Responses |
| | | INFO_CTRL_PANEL_MOD_REQUESTS_LABEL=Modify Requests |
| | | INFO_CTRL_PANEL_MOD_RESPONSES_LABEL=Modify Responses |
| | | INFO_CTRL_PANEL_SEARCH_REQUESTS_LABEL=Search Requests |
| | | INFO_CTRL_PANEL_SEARCH_DONE_LABEL=Searches Done |
| | | INFO_CTRL_PANEL_UNBIND_REQUESTS_LABEL=Unbind Requests |
| | | INFO_CTRL_PANEL_ALL_CONNECTION_HANDLERS=All |
| | | INFO_CTRL_PANEL_CONNECTION_HANDLERS_LABEL=Connection Handlers: |
| | | INFO_CTRL_PANEL_CONNECTION_HANDLER_MONITORING_TITLE=Connection Handler \ |
| | | Monitoring |
| | | INFO_CTRL_PANEL_AUTH_REQUIRED_TO_SEE_TRAFFIC_MONITORING_SUMMARY=The \ |
| | | server is running. You must provide authentication to see the monitoring data. |
| | | INFO_CTRL_PANEL_SERVER_MUST_RUN_TO_SEE_TRAFFIC_MONITORING_SUMMARY=To \ |
| | | see the monitoring data the server must be running and you must provide \ |
| | | authentication. |
| | | INFO_CTRL_PANEL_ADMINISTRATION_CONNECTOR_NAME=%d - Administration \ |
| | | Connector |
| | | INFO_CTRL_PANEL_CONNECTION_HANDLER_VIEW_MENU=View |
| | | INFO_CTRL_PANEL_CONNECTION_HANDLER_VIEW_MENU_DESCRIPTION=View options \ |
| | | for the Connection Handler Monitoring |
| | | INFO_CTRL_PANEL_SHOW_AVERAGES=Show Averages |
| | | INFO_CTRL_PANEL_CONNECTION_HANDLER_HEADER=Connection Handler |
| | | INFO_CTRL_PANEL_ADMINISTRATION_CONNECTOR_NAME=%d - Administration \ |
| | | Connector |
| | | INFO_CTRL_PANEL_CONNECTION_HANDLER_MONITORING=Connection Handler |
| | | INFO_CTRL_PANEL_AVERAGE_HEADER=%s Avg per second |