| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006 Sun Microsystems, Inc. |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | import org.opends.server.util.TimeThread; |
| | | |
| | | import static org.opends.server.loggers.Debug.*; |
| | | |
| | | /** |
| | | * This class implements a fixed time based rotation policy. |
| | | * Rotation will happen N seconds since the last rotation. |
| | | */ |
| | | public class TimeLimitRotationPolicy implements RotationPolicy |
| | | { |
| | | private static final String CLASS_NAME = |
| | | "org.opends.server.loggers.TimeLimitRotationPolicy"; |
| | | |
| | | private long timeInterval = 0; |
| | | private long lastModifiedTime = 0; |
| | |
| | | */ |
| | | public TimeLimitRotationPolicy(long time) |
| | | { |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(time)); |
| | | |
| | | timeInterval = time; |
| | | lastModifiedTime = TimeThread.getTime(); |
| | | } |
| | |
| | | */ |
| | | public boolean rotateFile() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "rotateFile"); |
| | | |
| | | long currTime = TimeThread.getTime(); |
| | | if(currTime - lastModifiedTime > timeInterval) |
| | | if (currTime - lastModifiedTime > timeInterval) |
| | | { |
| | | do |
| | | { |
| | | lastModifiedTime += timeInterval; |
| | | } while (lastModifiedTime < currTime); |
| | | } |
| | | while (lastModifiedTime < currTime); |
| | | |
| | | // lastModifiedTime = currTime; |
| | | return true; |