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

Nicolas Capponi
22.51.2014 db364b9d90deb67f8c9928d79299d68512853efb
opendj3-server-dev/src/messages/messages/replication.properties
@@ -584,4 +584,26 @@
 file and actual domain directories found in file system. Expected domain ids : '%s'. \
 Actual domain ids found in file system: '%s'
ERR_CHANGELOG_UNABLE_TO_UPDATE_DOMAIN_STATE_FILE_265=Could not create a new domain \
 id %s for domain DN %s and save it in domain state file '%s"
 id %s for domain DN %s and save it in domain state file '%s"
ERR_CHANGELOG_UNABLE_TO_GET_CURSOR_READER_POSITION_LOG_FILE_266=Could not get reader \
 position for cursor in log file '%s'
ERR_CHANGELOG_UNABLE_TO_DECODE_KEY_FROM_STRING_267=Could not decode the key from \
 string [%s]
ERR_CHANGELOG_CURSOR_OPENED_WHILE_CLEANING_LOG_268=When cleaning log '%s', \
 found %d cursor(s) still opened on the log
ERR_CHANGELOG_CURSOR_OPENED_WHILE_CLOSING_LOG_269=When closing log '%s', \
 found %d cursor(s) still opened on the log
ERR_CHANGELOG_UNABLE_TO_INITIALIZE_LOG_270=Could not initialize \
 the log '%s'
ERR_CHANGELOG_UNABLE_TO_RETRIEVE_KEY_BOUNDS_FROM_FILE_271=Could not \
 retrieve key bounds from log file '%s'
ERR_CHANGELOG_UNABLE_TO_RETRIEVE_READ_ONLY_LOG_FILES_LIST_272=Could not \
 retrieve read-only log files from log '%s'
ERR_CHANGELOG_UNABLE_TO_DELETE_LOG_FILE_WHILE_PURGING_273=While purging log, could not \
 delete log file(s): '%s'
ERR_CHANGELOG_UNREFERENCED_LOG_WHILE_RELEASING_274 =The following log \
 '%s' must be released but it is not referenced."
ERR_CHANGELOG_UNABLE_TO_RENAME_HEAD_LOG_FILE_275=Could not rename \
 head log file from '%s' to '%s'
INFO_CHANGELOG_LOG_FILE_ROTATION_276=Rotation needed for log file '%s', \
 size of head log file is %d bytes
opendj3-server-dev/src/server/org/opends/server/loggers/FixedTimeRotationPolicy.java
@@ -107,7 +107,7 @@
  /**
   * {@inheritDoc}
   */
  public boolean rotateFile(MultifileTextWriter writer)
  public boolean rotateFile(RotatableLogFile writer)
  {
    Calendar lastRotationTime = writer.getLastRotationTime();
opendj3-server-dev/src/server/org/opends/server/loggers/MeteredStream.java
@@ -22,6 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.server.loggers;
@@ -33,7 +34,7 @@
 *  (a) forwards all its output to a target stream
 *  (b) keeps track of how many bytes have been written.
 */
class MeteredStream extends OutputStream
public final class MeteredStream extends OutputStream
{
  OutputStream out;
  long written;
@@ -45,7 +46,7 @@
   * @param out     The target output stream to keep track of.
   * @param written The number of bytes written to the stream.
   */
  MeteredStream(OutputStream out, long written)
  public MeteredStream(OutputStream out, long written)
  {
    this.out = out;
    this.written = written;
@@ -111,5 +112,15 @@
  {
    out.close();
  }
  /**
   * Returns the number of bytes written in this stream.
   *
   * @return the number of bytes
   */
  public long getBytesWritten()
  {
    return written;
  }
}
opendj3-server-dev/src/server/org/opends/server/loggers/MultifileTextWriter.java
@@ -59,7 +59,7 @@
 * new one named in accordance with a specified FileNamingPolicy.
 */
class MultifileTextWriter
    implements ServerShutdownListener, TextWriter,
    implements ServerShutdownListener, TextWriter, RotatableLogFile,
    ConfigurationChangeListener<SizeLimitLogRotationPolicyCfg>
{
@@ -662,11 +662,8 @@
    this.actions = actions;
  }
  /**
   * Retrieves the number of bytes written to the current log file.
   *
   * @return The number of bytes written to the current log file.
   */
  /** {@inheritDoc} */
  @Override
  public long getBytesWritten()
  {
    return outputStream.written;
@@ -694,13 +691,8 @@
    return lastCleanCount;
  }
  /**
   * Retrieves the last time a log file was rotated in this instance of
   * Directory Server. If a log rotation never
   * occurred, this value will be the time the server started.
   *
   * @return The last time log rotation occurred.
   */
  /** {@inheritDoc} */
  @Override
  public Calendar getLastRotationTime()
  {
    return lastRotationTime;
opendj3-server-dev/src/server/org/opends/server/loggers/RotatableLogFile.java
New file
@@ -0,0 +1,51 @@
/*
 * 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 legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * 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 legal-notices/CDDLv1_0.txt.
 * 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 2014 ForgeRock AS.
 */
package org.opends.server.loggers;
import java.util.Calendar;
/**
 * Represents a file that can be rotated based on size or on time.
 */
public interface RotatableLogFile
{
  /**
   * Retrieves the number of bytes written to the file.
   *
   * @return The number of bytes written to the file.
   */
  long getBytesWritten();
  /**
   * Retrieves the last time the file was rotated. If a file rotation never
   * occurred, this value will be the time the server started.
   *
   * @return The last time file rotation occurred.
   */
  Calendar getLastRotationTime();
}
opendj3-server-dev/src/server/org/opends/server/loggers/RotationPolicy.java
@@ -61,14 +61,13 @@
  /**
   * This method indicates if the log file should be
   * rotated or not.
   * This method indicates if the log file should be rotated or not.
   *
   * @param writer The multi file writer writing the file to be
   *        checked.
   * @param writer
   *          the file writer to be checked.
   * @return true if the log file should be rotated, false otherwise.
   */
  public boolean rotateFile(MultifileTextWriter writer);
  public boolean rotateFile(RotatableLogFile writer);
}
opendj3-server-dev/src/server/org/opends/server/loggers/SizeBasedRotationPolicy.java
@@ -98,7 +98,7 @@
   * @param writer The multi file text writer writing the log file.
   * @return true if the file needs to be rotated, false otherwise.
  */
  public boolean rotateFile(MultifileTextWriter writer)
  public boolean rotateFile(RotatableLogFile writer)
  {
    long fileSize = writer.getBytesWritten();
opendj3-server-dev/src/server/org/opends/server/loggers/TimeLimitRotationPolicy.java
@@ -91,7 +91,7 @@
   * @param writer The mutli file text writer written the log file.
   * @return true if the file should be rotated, false otherwise.
   */
  public boolean rotateFile(MultifileTextWriter writer)
  public boolean rotateFile(RotatableLogFile writer)
  {
    long currInterval = TimeThread.getTime() -
        writer.getLastRotationTime().getTimeInMillis();
opendj3-server-dev/src/server/org/opends/server/replication/common/CSN.java
@@ -61,6 +61,9 @@
   */
  public static final int STRING_ENCODING_LENGTH = 28;
  /** The maximum possible value for a CSN. */
  public static final CSN MAX_CSN_VALUE = new CSN(Long.MAX_VALUE, Integer.MAX_VALUE, Short.MAX_VALUE);
  private static final long serialVersionUID = -8802722277749190740L;
  private final long timeStamp;
  /**
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
@@ -1105,6 +1105,13 @@
    return new File(testResourceDir, filename);
  }
  public static File getUnitTestRootPath()
  {
    final String buildRoot = System.getProperty(PROPERTY_BUILD_ROOT);
    final String path = System.getProperty(PROPERTY_BUILD_DIR, buildRoot + File.separator + "build");
    return new File(path, "unit-tests");
  }
  /**
   * Prevent instantiation.
   */
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/ChangeNumberControlPluginTestCase.java
@@ -79,6 +79,7 @@
        + "cn: Replication Server\n"
        + "ds-cfg-replication-port: " + replServerPort + "\n"
        + "ds-cfg-replication-db-directory: ChangeNumberControlDbTest\n"
        + "ds-cfg-replication-db-implementation: " + replicationDbImplementation + "\n"
        + "ds-cfg-replication-server-id: 103\n";
    // suffix synchronized
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/ReSyncTest.java
@@ -93,6 +93,7 @@
        + "cn: Replication Server\n"
        + "ds-cfg-replication-port:" + replServerPort + "\n"
        + "ds-cfg-replication-db-directory: ReSyncTest\n"
        + "ds-cfg-replication-db-implementation: " + replicationDbImplementation + "\n"
        + "ds-cfg-replication-server-id: 104\n";
    // suffix synchronized
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalTest.java
@@ -84,6 +84,7 @@
         + "cn: replication Server\n"
         + "ds-cfg-replication-port: " + replServerPort + "\n"
         + "ds-cfg-replication-db-directory: HistoricalTest\n"
         + "ds-cfg-replication-db-implementation: " + replicationDbImplementation + "\n"
         + "ds-cfg-replication-server-id: 102\n";
    // The suffix to be synchronized.