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

Jean-Noël Rouvignac
27.19.2016 ff469126490bc6aef04f188d6a16c52913ed0e31
code cleanups
4 files modified
47 ■■■■■ changed files
opendj-core/src/main/java/com/forgerock/opendj/ldap/controls/AffinityControl.java 6 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/Connections.java 5 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/RequestLoadBalancer.java 1 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRuleImpl.java 35 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/com/forgerock/opendj/ldap/controls/AffinityControl.java
@@ -29,9 +29,11 @@
/**
 * Control that provides a value for affinity.
 * <p>
 * As an example, this control can be used for connection affinity when using a load-balancer ({@link Connections}).
 * As an example, this control can be used for connection affinity when using a load-balancer (
 * {@link org.forgerock.opendj.ldap.Connections Connections}).
 *
 * @see Connections#newLeastRequestsLoadBalancer(Collection, Options)
 * @see org.forgerock.opendj.ldap.Connections#newLeastRequestsLoadBalancer(java.util.Collection,
 *      org.forgerock.util.Options)
 */
public final class AffinityControl implements Control {
opendj-core/src/main/java/org/forgerock/opendj/ldap/Connections.java
@@ -14,7 +14,6 @@
 * Copyright 2009-2010 Sun Microsystems, Inc.
 * Portions Copyright 2011-2016 ForgeRock AS.
 */
package org.forgerock.opendj.ldap;
import static org.forgerock.opendj.ldap.RequestHandlerFactoryAdapter.adaptRequestHandler;
@@ -60,7 +59,6 @@
 * factories and connections.
 */
public final class Connections {
    private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
    /**
@@ -562,7 +560,6 @@
                                       options,
                                       newShardedRequestLoadBalancerNextFunction(factories),
                                       NOOP_END_OF_REQUEST_FUNCTION);
    }
    static Function<Request, RequestWithIndex, NeverThrowsException> newShardedRequestLoadBalancerNextFunction(
@@ -777,7 +774,7 @@
        private int getLessSaturatedIndex() {
            long min = Long.MAX_VALUE;
            int minIndex = -1;
            // Modifications during this loop are ok, effects on result is should not be dramatic
            // Modifications during this loop are ok, effects on result should not be dramatic
            for (int i = 0; i < serversCounters.length(); i++) {
                long count = serversCounters.get(i);
                if (count < min) {
opendj-core/src/main/java/org/forgerock/opendj/ldap/RequestLoadBalancer.java
@@ -315,7 +315,6 @@
            this.connectionPromise = connectionPromise;
        }
        Connection getConnection() {
            return connectionHolder.get();
        }
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRuleImpl.java
@@ -37,9 +37,7 @@
import static org.opends.messages.ReplicationMessages.*;
import static org.opends.server.util.StaticUtils.*;
/**
 * Matching rule used to establish an order between historical information and index them.
 */
/** Matching rule used to establish an order between historical information and index them. */
public final class HistoricalCsnOrderingMatchingRuleImpl implements MatchingRuleImpl
{
  private static final String ORDERING_ID = "changeSequenceNumberOrderingMatch";
@@ -64,16 +62,15 @@
    @Override
    public String keyToHumanReadableString(ByteSequence key)
    {
      ByteStringBuilder bsb = new ByteStringBuilder();
      bsb.appendBytes(key.subSequence(2, 10));
      bsb.appendBytes(key.subSequence(0, 2));
      bsb.appendBytes(key.subSequence(10, 14));
      CSN csn = CSN.valueOf(bsb.toByteString());
      return csn.toStringUI();
      ByteString bs = new ByteStringBuilder()
          .appendBytes(key.subSequence(2, 10))
          .appendBytes(key.subSequence(0, 2))
          .appendBytes(key.subSequence(10, 14))
          .toByteString();
      return CSN.valueOf(bs).toStringUI();
    }
  }
  /** {@inheritDoc} */
  @Override
  public ByteString normalizeAttributeValue(Schema schema, ByteSequence value) throws DecodeException
  {
@@ -86,21 +83,19 @@
    {
      int csnIndex = value.toString().indexOf(':') + 1;
      String csn = value.subSequence(csnIndex, csnIndex + 28).toString();
      ByteStringBuilder builder = new ByteStringBuilder(14);
      builder.appendBytes(hexStringToByteArray(csn.substring(16, 20)));
      builder.appendBytes(hexStringToByteArray(csn.substring(0, 16)));
      builder.appendBytes(hexStringToByteArray(csn.substring(20, 28)));
      return builder.toByteString();
      return new ByteStringBuilder(14)
          .appendBytes(hexStringToByteArray(csn.substring(16, 20)))
          .appendBytes(hexStringToByteArray(csn.substring(0, 16)))
          .appendBytes(hexStringToByteArray(csn.substring(20, 28)))
          .toByteString();
    }
    catch (Exception e)
    {
      // This should never occur in practice since these attributes are managed
      // internally.
      // This should never occur in practice since these attributes are managed internally.
      throw DecodeException.error(WARN_INVALID_SYNC_HIST_VALUE.get(value), e);
    }
  }
  /** {@inheritDoc} */
  @Override
  public Assertion getAssertion(final Schema schema, final ByteSequence value) throws DecodeException
  {
@@ -121,7 +116,6 @@
    };
  }
  /** {@inheritDoc} */
  @Override
  public Assertion getSubstringAssertion(Schema schema, ByteSequence subInitial,
      List<? extends ByteSequence> subAnyElements, ByteSequence subFinal) throws DecodeException
@@ -129,7 +123,6 @@
    return UNDEFINED_ASSERTION;
  }
  /** {@inheritDoc} */
  @Override
  public Assertion getGreaterOrEqualAssertion(Schema schema, ByteSequence value) throws DecodeException
  {
@@ -150,7 +143,6 @@
    };
  }
  /** {@inheritDoc} */
  @Override
  public Assertion getLessOrEqualAssertion(Schema schema, ByteSequence value) throws DecodeException
  {
@@ -176,5 +168,4 @@
  {
    return indexers;
  }
}