| | |
| | | package com.forgerock.opendj.cli; |
| | | |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | import static com.forgerock.opendj.cli.CliConstants.DEFAULT_LDAP_CONNECT_TIMEOUT; |
| | | import static com.forgerock.opendj.cli.CliConstants.DEFAULT_LDAP_PORT; |
| | | import static com.forgerock.opendj.cli.CliMessages.*; |
| | | import static com.forgerock.opendj.cli.Utils.getHostNameForLdapUrl; |
| | |
| | | /** If this connection should be an admin connection. */ |
| | | private boolean isAdminConnection; |
| | | |
| | | /** The port to use when the port argument has no default value. */ |
| | | private final int defaultPort; |
| | | |
| | | /** |
| | | * Default constructor to create a connection factory designed for use with command line tools, |
| | | * adding basic LDAP connection arguments to the specified parser (e.g: hostname, bindname...etc). |
| | |
| | | final ConsoleApplication app, final String defaultBindDN, final int defaultPort, |
| | | final boolean alwaysSSL) throws ArgumentException { |
| | | this.app = app; |
| | | this.defaultPort = defaultPort; |
| | | |
| | | useSSLArg = useSSLArgument(); |
| | | if (!alwaysSSL) { |
| | |
| | | try { |
| | | return connectTimeOut.getIntValue(); |
| | | } catch (ArgumentException e) { |
| | | return Integer.valueOf(connectTimeOut.getDefaultValue()); |
| | | return getDefaultConnectTimeout(); |
| | | } |
| | | } |
| | | return Integer.valueOf(connectTimeOut.getDefaultValue()); |
| | | return getDefaultConnectTimeout(); |
| | | } |
| | | |
| | | private int getDefaultConnectTimeout() { |
| | | return connectTimeOut.getDefaultIntValue(DEFAULT_LDAP_CONNECT_TIMEOUT); |
| | | } |
| | | |
| | | |
| | |
| | | try { |
| | | return portArg.getIntValue(); |
| | | } catch (ArgumentException e) { |
| | | return Integer.valueOf(portArg.getDefaultValue()); |
| | | return getDefaultPort(); |
| | | } |
| | | } else if (app.isInteractive()) { |
| | | final LocalizableMessage portMsg = |
| | | isAdminConnection ? INFO_DESCRIPTION_ADMIN_PORT.get() : INFO_DESCRIPTION_PORT.get(); |
| | | int value = app.askPort(portMsg, Integer.valueOf(portArg.getDefaultValue()), logger); |
| | | int value = app.askPort(portMsg, getDefaultPort(), logger); |
| | | app.println(); |
| | | portArg.addValue(Integer.toString(value)); |
| | | portArg.setPresent(true); |
| | | return value; |
| | | } |
| | | return Integer.valueOf(portArg.getDefaultValue()); |
| | | return getDefaultPort(); |
| | | } |
| | | |
| | | private int getDefaultPort() { |
| | | return portArg.getDefaultIntValue(defaultPort); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | * Portions Copyright 2026 3A Systems, LLC. |
| | | */ |
| | | package com.forgerock.opendj.cli; |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the default value of this argument as an int. |
| | | * <p> |
| | | * The default value of an integer argument is always built from an {@code int}, so the only |
| | | * reason for this method to return the fallback value is that this argument has no default |
| | | * value at all. |
| | | * |
| | | * @param fallbackValue |
| | | * The value to return if this argument does not have a default value. |
| | | * @return The default value of this argument, or {@code fallbackValue} if it does not have one. |
| | | */ |
| | | public int getDefaultIntValue(final int fallbackValue) { |
| | | try { |
| | | return Integer.parseInt(getDefaultValue()); |
| | | } catch (final NumberFormatException e) { |
| | | return fallbackValue; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in this |
| | | * argument. |
| | | * |
| | |
| | | */ |
| | | public static void checkJavaVersion() throws ClientException { |
| | | final String version = System.getProperty("java.specification.version"); |
| | | if (Float.valueOf(version) < CliConstants.MINIMUM_JAVA_VERSION) { |
| | | if (getJavaSpecificationVersion(version) < CliConstants.MINIMUM_JAVA_VERSION) { |
| | | final String javaBin = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; |
| | | throw new ClientException(ReturnCode.JAVA_VERSION_INCOMPATIBLE, |
| | | ERR_INCOMPATIBLE_JAVA_VERSION.get(CliConstants.MINIMUM_JAVA_VERSION, version, javaBin), null); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the provided java specification version as a number, or zero if it does not hold one, |
| | | * in which case the java version is reported as incompatible rather than failing the check with |
| | | * a runtime exception. |
| | | */ |
| | | private static float getJavaSpecificationVersion(final String version) { |
| | | if (version == null) { |
| | | return 0; |
| | | } |
| | | try { |
| | | return Float.parseFloat(version); |
| | | } catch (final NumberFormatException e) { |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns the default host name. |
| | | * |
| | | * @return The default host name or empty string if the host name cannot be resolved. |
| | |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | * Portions Copyright 2026 3A Systems, LLC. |
| | | */ |
| | | package com.forgerock.opendj.ldap.tools; |
| | | |
| | |
| | | |
| | | double[] getPercentiles() { |
| | | if (percentilesArgument.isPresent()) { |
| | | double[] percentiles = new double[percentilesArgument.getValues().size()]; |
| | | int index = 0; |
| | | for (final String percentile : percentilesArgument.getValues()) { |
| | | percentiles[index++] = Double.parseDouble(percentile); |
| | | try { |
| | | final double[] percentiles = new double[percentilesArgument.getValues().size()]; |
| | | int index = 0; |
| | | for (final String percentile : percentilesArgument.getValues()) { |
| | | percentiles[index++] = Double.parseDouble(percentile); |
| | | } |
| | | Arrays.sort(percentiles); |
| | | return percentiles; |
| | | } catch (final NumberFormatException e) { |
| | | // The argument parser only accepts integers in the [0, 100] range, so this cannot |
| | | // happen. Fall back to the default percentiles rather than failing the run. |
| | | } |
| | | Arrays.sort(percentiles); |
| | | return percentiles; |
| | | } |
| | | |
| | | return DEFAULT_PERCENTILES; |
| | |
| | | import org.opends.guitools.controlpanel.task.DeleteIndexTask; |
| | | import org.opends.guitools.controlpanel.task.Task; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.quicksetup.util.Utils; |
| | | |
| | | /** |
| | | * The panel that displays an existing index (it appears on the right of the |
| | |
| | | backendSet = new HashSet<>(); |
| | | backendSet.add(backendName); |
| | | attributeName = index.getName(); |
| | | entryLimitValue = Integer.parseInt(entryLimit.getText()); |
| | | entryLimitValue = Utils.parseIntOrDefault(entryLimit.getText(), index.getEntryLimit()); |
| | | indexTypes = getTypes(); |
| | | |
| | | indexToModify = index; |
| | |
| | | |
| | | private HostPort getHostPort() |
| | | { |
| | | return new HostPort(hostName.getText().trim(), Integer.valueOf(port.getText().trim())); |
| | | return new HostPort(hostName.getText().trim(), Utils.parseIntOrDefault(port.getText(), -1)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | else if (importAutomaticallyGenerated.isSelected()) |
| | | { |
| | | int nEntries = Integer.parseInt(numberOfEntries.getText().trim()); |
| | | int nEntries = Utils.parseIntOrDefault(numberOfEntries.getText(), 0); |
| | | if (nEntries < 500) |
| | | { |
| | | return 30; |
| | |
| | | } |
| | | }); |
| | | |
| | | final File templateFile = SetupUtils.createTemplateFile(newBaseDN, Integer.parseInt(nEntries)); |
| | | final File templateFile = |
| | | SetupUtils.createTemplateFile(newBaseDN, Utils.parseIntOrDefault(nEntries, 0)); |
| | | if (!isLocal()) |
| | | { |
| | | try |
| | |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.task.Task; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | |
| | | /** Panel that appears when the user defines a new index. */ |
| | |
| | | super(info, dlg); |
| | | backendSet.add(backendName.getText()); |
| | | attributeName = getAttributeName(); |
| | | entryLimitValue = Integer.parseInt(entryLimit.getText()); |
| | | entryLimitValue = Utils.parseIntOrDefault(entryLimit.getText(), DEFAULT_ENTRY_LIMIT); |
| | | indexTypes = getTypes(); |
| | | } |
| | | |
| | |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | * Portions Copyright 2026 3A Systems, LLC. |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | |
| | | import org.opends.guitools.controlpanel.ui.components.TimeDocumentFilter; |
| | | import org.opends.guitools.controlpanel.ui.renderer.NoLeftInsetCategoryComboBoxRenderer; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.server.backends.task.RecurringTask; |
| | | |
| | | /** The panel that allows the user to specify when a task will be launched. */ |
| | |
| | | |
| | | int previousErrorNumber = errorMessages.size(); |
| | | |
| | | int y = Integer.parseInt(year.getSelectedItem().toString()); |
| | | int y = Utils.parseIntOrDefault(year.getSelectedItem().toString(), -1); |
| | | int d = -1; |
| | | int m = month.getSelectedIndex(); |
| | | int[] h = {-1}; |
| | |
| | | { |
| | | return NO_VALUE_SET.toString(); |
| | | } |
| | | long l = Long.parseLong(monitoringValue); |
| | | Date date = new Date(l); |
| | | return ConfigFromConnection.newDateFormatter().format(date); |
| | | try |
| | | { |
| | | Date date = new Date(Long.parseLong(monitoringValue)); |
| | | return ConfigFromConnection.newDateFormatter().format(date); |
| | | } |
| | | catch (NumberFormatException e) |
| | | { |
| | | // The server did not return a number: display the value as it is. |
| | | return monitoringValue; |
| | | } |
| | | } |
| | | else if (attr.isTime()) |
| | | { |
| | |
| | | } |
| | | else if (attr.isValueInBytes()) |
| | | { |
| | | long l = Long.parseLong(monitoringValue); |
| | | long mb = l / (1024 * 1024); |
| | | long kbs = (l - mb * 1024 * 1024) / 1024; |
| | | return INFO_CTRL_PANEL_MEMORY_VALUE.get(mb, kbs).toString(); |
| | | try |
| | | { |
| | | long l = Long.parseLong(monitoringValue); |
| | | long mb = l / (1024 * 1024); |
| | | long kbs = (l - mb * 1024 * 1024) / 1024; |
| | | return INFO_CTRL_PANEL_MEMORY_VALUE.get(mb, kbs).toString(); |
| | | } |
| | | catch (NumberFormatException e) |
| | | { |
| | | // The server did not return a number: display the value as it is. |
| | | return monitoringValue; |
| | | } |
| | | } |
| | | return monitoringValue; |
| | | } |
| | |
| | | * @return String representing the major version |
| | | */ |
| | | public Integer getMajorVersion() { |
| | | return Integer.valueOf(values.get(MAJOR_VERSION)); |
| | | return getVersionNumber(MAJOR_VERSION); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return String representing the minor version |
| | | */ |
| | | public Integer getMinorVersion() { |
| | | return Integer.valueOf(values.get(MINOR_VERSION)); |
| | | return getVersionNumber(MINOR_VERSION); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return String representing the point version |
| | | */ |
| | | public Integer getPointVersion() { |
| | | return Integer.valueOf(values.get(POINT_VERSION)); |
| | | return getVersionNumber(POINT_VERSION); |
| | | } |
| | | |
| | | /** |
| | | * Returns the number held by the provided version property, or zero if the |
| | | * build information does not hold a number for it. |
| | | * |
| | | * @param versionProperty the name of the version property |
| | | * @return the number held by the property |
| | | */ |
| | | private Integer getVersionNumber(String versionProperty) { |
| | | try { |
| | | return Integer.valueOf(values.get(versionProperty)); |
| | | } catch (NumberFormatException e) { |
| | | // The build information does not hold a version number: treat it as unknown |
| | | // rather than failing the version comparison with a runtime exception. |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | if (errorMsgs.isEmpty()) |
| | | { |
| | | port = Integer.parseInt(sPort); |
| | | port = Utils.parseIntOrDefault(sPort, -1); |
| | | // Try to connect |
| | | boolean[] globalAdmin = { hasGlobalAdministrators }; |
| | | DN[] effectiveDn = { dn }; |
| | |
| | | ui.displayFieldInvalid(FieldName.NUMBER_ENTRIES, !fieldIsValid); |
| | | if (validBaseDn && localErrorMsgs.isEmpty()) |
| | | { |
| | | return NewSuffixOptions.createAutomaticallyGenerated(baseDn, Integer.parseInt(nEntries)); |
| | | return NewSuffixOptions.createAutomaticallyGenerated(baseDn, Utils.parseIntOrDefault(nEntries, 0)); |
| | | } |
| | | errorMsgs.addAll(localErrorMsgs); |
| | | |
| | |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | * Portions Copyright 2026 3A Systems, LLC. |
| | | */ |
| | | |
| | | package org.opends.quicksetup.installer.ui; |
| | |
| | | String sMaxMemory = tfMaxMemory.getText().trim(); |
| | | if (sMaxMemory.length() > 0) |
| | | { |
| | | javaArguments.setMaxMemory(Integer.parseInt(sMaxMemory)); |
| | | javaArguments.setMaxMemory(Utils.parseIntOrDefault(sMaxMemory, -1)); |
| | | } |
| | | String sInitialMemory = tfInitialMemory.getText().trim(); |
| | | if (sInitialMemory.length() > 0) |
| | | { |
| | | javaArguments.setInitialMemory(Integer.parseInt(sInitialMemory)); |
| | | javaArguments.setInitialMemory(Utils.parseIntOrDefault(sInitialMemory, -1)); |
| | | } |
| | | String[] args = getOtherArguments(); |
| | | if (args.length > 0) |
| | |
| | | { |
| | | String s = String.valueOf(l); |
| | | String[] colors = s.split(","); |
| | | int r = Integer.parseInt(colors[0].trim()); |
| | | int g = Integer.parseInt(colors[1].trim()); |
| | | int b = Integer.parseInt(colors[2].trim()); |
| | | try |
| | | { |
| | | int r = Integer.parseInt(colors[0].trim()); |
| | | int g = Integer.parseInt(colors[1].trim()); |
| | | int b = Integer.parseInt(colors[2].trim()); |
| | | |
| | | return new Color(r, g, b); |
| | | return new Color(r, g, b); |
| | | } |
| | | catch (NumberFormatException | IndexOutOfBoundsException e) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Invalid color definition \"%s\", using black instead", s)); |
| | | return Color.BLACK; |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | cmdLines.add(cmdReplicationServer); |
| | | return cmdLines; |
| | | } |
| | | |
| | | /** |
| | | * Returns the number held by the provided field value, or the provided default value if it does |
| | | * not hold a number. |
| | | * <p> |
| | | * The panels validate their fields before using their values, so the default value is only |
| | | * returned when a field has not been validated beforehand. |
| | | * |
| | | * @param value |
| | | * the value to be parsed, which may be {@code null} |
| | | * @param defaultValue |
| | | * the value to return when {@code value} does not hold a number |
| | | * @return the number held by the provided value |
| | | */ |
| | | public static int parseIntOrDefault(String value, int defaultValue) |
| | | { |
| | | if (value == null) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | try |
| | | { |
| | | return Integer.parseInt(value.trim()); |
| | | } |
| | | catch (NumberFormatException e) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011 profiq s.r.o. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | * Portions Copyright 2026 3A Systems, LLC. |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | |
| | | } |
| | | |
| | | lastResetDirectoryManagerDN = DN.valueOf(argParser.directoryManagerDNArg.getDefaultValue()); |
| | | lastResetLdapPort = Integer.parseInt(argParser.ldapPortArg.getDefaultValue()); |
| | | lastResetLdapsPort = Integer.parseInt(argParser.ldapsPortArg.getDefaultValue()); |
| | | lastResetAdminConnectorPort = Integer.parseInt(argParser.adminConnectorPortArg.getDefaultValue()); |
| | | lastResetJmxPort = Integer.parseInt(argParser.jmxPortArg.getDefaultValue()); |
| | | lastResetLdapPort = argParser.ldapPortArg.getDefaultIntValue(-1); |
| | | lastResetLdapsPort = argParser.ldapsPortArg.getDefaultIntValue(-1); |
| | | lastResetAdminConnectorPort = argParser.adminConnectorPortArg.getDefaultIntValue(-1); |
| | | lastResetJmxPort = argParser.jmxPortArg.getDefaultIntValue(-1); |
| | | |
| | | // Validate user provided data |
| | | try |
| | |
| | | } |
| | | else if (argParser.sampleDataArg.isPresent()) |
| | | { |
| | | dataOptions = NewSuffixOptions.createAutomaticallyGenerated(baseDNs, |
| | | Integer.valueOf(argParser.sampleDataArg.getValue())); |
| | | try |
| | | { |
| | | dataOptions = NewSuffixOptions.createAutomaticallyGenerated(baseDNs, argParser.sampleDataArg.getIntValue()); |
| | | } |
| | | catch (final ArgumentException ae) |
| | | { |
| | | errorMessages.add(ae.getMessageObject()); |
| | | dataOptions = NewSuffixOptions.createEmpty(baseDNs); |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | * Portions Copyright 2026 3A Systems, LLC. |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | |
| | | } |
| | | // Figure out when to stop waiting. |
| | | long stopWaitingTime; |
| | | int timeoutSeconds; |
| | | try |
| | | { |
| | | long timeoutMillis = 1000L * Integer.parseInt(timeout.getValue()); |
| | | timeoutSeconds = Integer.parseInt(timeout.getValue()); |
| | | long timeoutMillis = 1000L * timeoutSeconds; |
| | | if (timeoutMillis > 0) |
| | | { |
| | | stopWaitingTime = System.currentTimeMillis() + timeoutMillis; |
| | |
| | | catch (Exception e) |
| | | { |
| | | // This shouldn't happen, but if it does then ignore it. |
| | | timeoutSeconds = 60; |
| | | stopWaitingTime = System.currentTimeMillis() + 60000; |
| | | } |
| | | |
| | |
| | | |
| | | if (targetFile.exists()) |
| | | { |
| | | println(ERR_TIMEOUT_DURING_STARTUP.get( |
| | | Integer.parseInt(timeout.getValue()), |
| | | timeout.getLongIdentifier())); |
| | | println(ERR_TIMEOUT_DURING_STARTUP.get(timeoutSeconds, timeout.getLongIdentifier())); |
| | | return EXIT_CODE_TIMEOUT; |
| | | } |
| | | else |
| | |
| | | * |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | * Portions Copyright 2026 3A Systems, LLC. |
| | | */ |
| | | package org.opends.server.tools.dsreplication; |
| | | |
| | |
| | | */ |
| | | static int getDefaultValue(IntegerArgument arg) |
| | | { |
| | | String v = arg.getDefaultValue(); |
| | | return v != null ? Integer.parseInt(v) : -1; |
| | | return arg.getDefaultIntValue(-1); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | * Portions Copyright 2026 3A Systems, LLC. |
| | | */ |
| | | package org.opends.server.tools.tasks; |
| | | |
| | |
| | | } |
| | | return 0; |
| | | } catch (LDAPConnectionException e) { |
| | | if (isWrongPortException(e, |
| | | Integer.valueOf(argParser.getArguments().getPort()))) |
| | | if (isWrongPortException(e, getPortNumber())) |
| | | { |
| | | printWrappedText(err, ERR_TASK_LDAP_FAILED_TO_CONNECT_WRONG_PORT.get( |
| | | argParser.getArguments().getHostName(), argParser.getArguments().getPort())); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the port this tool tried to connect to, or {@code -1} if the port argument does not |
| | | * hold a number, in which case the connection failure cannot be a wrong port one. |
| | | * @return the port this tool tried to connect to. |
| | | */ |
| | | private int getPortNumber() |
| | | { |
| | | try |
| | | { |
| | | return Integer.parseInt(argParser.getArguments().getPort()); |
| | | } |
| | | catch (NumberFormatException e) |
| | | { |
| | | return -1; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns {@code true} if the provided exception was caused by trying to |
| | | * connect to the wrong port and {@code false} otherwise. |
| | | * @param t the exception to be analyzed. |
| | |
| | | */ |
| | | @Override |
| | | public String getDsApplIfProtocol() { |
| | | String portNumber = (String)this.monitor.getAttribute |
| | | (this.connectionHandlerName, "ds-connectionhandler-listener"); |
| | | Object listener = this.monitor.getAttribute( |
| | | this.connectionHandlerName, "ds-connectionhandler-listener"); |
| | | if (listener instanceof Object[]) { |
| | | // A connection handler with several listen addresses reports them as an array. |
| | | Object[] listeners = (Object[]) listener; |
| | | listener = listeners.length > 0 ? listeners[0] : null; |
| | | } |
| | | String portNumber = listener != null ? String.valueOf(listener) : null; |
| | | if (portNumber==null) { |
| | | return this.DsApplIfProtocol; |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the value of the provided connection handler statistic as a |
| | | * counter, or zero if the statistic is not available or does not hold a |
| | | * number. |
| | | * |
| | | * @param statisticName the name of the connection handler statistic |
| | | * @return the counter value of the statistic |
| | | */ |
| | | private Long getCounter32Statistic(String statisticName) { |
| | | if (stats == null) { |
| | | stats = this.monitor.getConnectionHandlerStatistics( |
| | | connectionHandlerName); |
| | | } |
| | | if (stats == null) { |
| | | return 0L; |
| | | } |
| | | try { |
| | | long value = Long.parseLong( |
| | | String.valueOf(this.monitor.getAttribute(stats, statisticName))); |
| | | return SNMPMonitor.counter32Value(value); |
| | | } catch (NumberFormatException e) { |
| | | // The statistic is not available or is not a number. |
| | | return 0L; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | * @return DsApplIfSearchOps |
| | | */ |
| | | @Override |
| | | public Long getDsApplIfSearchOps() { |
| | | if (stats == null) { |
| | | stats = this.monitor.getConnectionHandlerStatistics( |
| | | connectionHandlerName); |
| | | } |
| | | if (stats != null) { |
| | | long value = Long.parseLong((String) this.monitor.getAttribute(stats, |
| | | "searchRequests")); |
| | | return SNMPMonitor.counter32Value(value); |
| | | } else { |
| | | return 0L; |
| | | } |
| | | return getCounter32Statistic("searchRequests"); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public Long getDsApplIfOneLevelSearchOps() { |
| | | if (stats == null) { |
| | | stats = this.monitor.getConnectionHandlerStatistics( |
| | | connectionHandlerName); |
| | | } |
| | | if (stats != null) { |
| | | long value = Long.parseLong((String) this.monitor.getAttribute(stats, |
| | | "searchOneRequests")); |
| | | return SNMPMonitor.counter32Value(value); |
| | | } else { |
| | | return 0L; |
| | | } |
| | | return getCounter32Statistic("searchOneRequests"); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public Long getDsApplIfWholeSubtreeSearchOps() { |
| | | if (stats == null) { |
| | | stats = this.monitor.getConnectionHandlerStatistics( |
| | | connectionHandlerName); |
| | | } |
| | | if (stats != null) { |
| | | long value = Long.parseLong((String) this.monitor.getAttribute(stats, |
| | | "searchSubRequests")); |
| | | return SNMPMonitor.counter32Value(value); |
| | | } else { |
| | | return 0L; |
| | | } |
| | | return getCounter32Statistic("searchSubRequests"); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public Long getDsApplIfModifyRDNOps() { |
| | | if (stats == null) { |
| | | stats = this.monitor.getConnectionHandlerStatistics( |
| | | connectionHandlerName); |
| | | } |
| | | if (stats != null) { |
| | | long value = Long.parseLong((String) this.monitor.getAttribute( |
| | | stats, "modifyDNRequests")); |
| | | return SNMPMonitor.counter32Value(value); |
| | | } else { |
| | | return 0L; |
| | | } |
| | | return getCounter32Statistic("modifyDNRequests"); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public Long getDsApplIfModifyEntryOps() { |
| | | if (stats == null) { |
| | | stats = this.monitor.getConnectionHandlerStatistics( |
| | | connectionHandlerName); |
| | | } |
| | | if (stats != null) { |
| | | long value = Long.parseLong((String) this.monitor.getAttribute( |
| | | stats, "modifyRequests")); |
| | | return SNMPMonitor.counter32Value(value); |
| | | } else { |
| | | return 0L; |
| | | } |
| | | return getCounter32Statistic("modifyRequests"); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public Long getDsApplIfRemoveEntryOps() { |
| | | if (stats == null) { |
| | | stats = this.monitor.getConnectionHandlerStatistics( |
| | | connectionHandlerName); |
| | | } |
| | | if (stats != null) { |
| | | long value = Long.parseLong((String) this.monitor.getAttribute( |
| | | stats, "deleteRequests")); |
| | | return SNMPMonitor.counter32Value(value); |
| | | } else { |
| | | return 0L; |
| | | } |
| | | return getCounter32Statistic("deleteRequests"); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public Long getDsApplIfAddEntryOps() { |
| | | if (stats == null) { |
| | | stats = this.monitor.getConnectionHandlerStatistics( |
| | | connectionHandlerName); |
| | | } |
| | | if (stats != null) { |
| | | long value = Long.parseLong((String) this.monitor.getAttribute( |
| | | stats, "addRequests")); |
| | | return SNMPMonitor.counter32Value(value); |
| | | } else { |
| | | return 0L; |
| | | } |
| | | return getCounter32Statistic("addRequests"); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public Long getDsApplIfCompareOps() { |
| | | if (stats == null) { |
| | | stats = this.monitor.getConnectionHandlerStatistics( |
| | | connectionHandlerName); |
| | | } |
| | | if (stats != null) { |
| | | long value = Long.parseLong((String) this.monitor.getAttribute( |
| | | stats, "compareRequests")); |
| | | return SNMPMonitor.counter32Value(value); |
| | | } else { |
| | | return 0L; |
| | | } |
| | | return getCounter32Statistic("compareRequests"); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public Long getDsApplIfOutBytes() { |
| | | if (stats == null) { |
| | | stats = this.monitor.getConnectionHandlerStatistics( |
| | | connectionHandlerName); |
| | | } |
| | | if (stats != null) { |
| | | long value = Long.parseLong((String) this.monitor.getAttribute( |
| | | stats, "bytesWritten")); |
| | | return SNMPMonitor.counter32Value(value); |
| | | } else { |
| | | return 0L; |
| | | } |
| | | return getCounter32Statistic("bytesWritten"); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public Long getDsApplIfInBytes() { |
| | | if (stats == null) { |
| | | stats = this.monitor.getConnectionHandlerStatistics( |
| | | connectionHandlerName); |
| | | } |
| | | if (stats != null) { |
| | | long value = Long.parseLong((String) this.monitor.getAttribute( |
| | | stats, "bytesRead")); |
| | | return SNMPMonitor.counter32Value(value); |
| | | } else { |
| | | return 0L; |
| | | } |
| | | return getCounter32Statistic("bytesRead"); |
| | | } |
| | | |
| | | /** |