mirror of https://github.com/apache/activemq.git
Merged in fixes from trunk
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/branches/activemq-4.0@425474 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
643fde4d28
commit
91156e667e
|
@ -73,14 +73,14 @@ final public class ControlFile {
|
||||||
synchronized (set) {
|
synchronized (set) {
|
||||||
if (lock == null) {
|
if (lock == null) {
|
||||||
if (!set.add(canonicalPath)) {
|
if (!set.add(canonicalPath)) {
|
||||||
throw new IOException("Journal is already opened by this application.");
|
throw new JournalLockedException("Journal is already opened by this application.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !brokenFileLock ) {
|
if( !brokenFileLock ) {
|
||||||
lock = channel.tryLock();
|
lock = channel.tryLock();
|
||||||
if (lock == null) {
|
if (lock == null) {
|
||||||
set.remove(canonicalPath);
|
set.remove(canonicalPath);
|
||||||
throw new IOException("Journal is already opened by another application");
|
throw new JournalLockedException("Journal is already opened by another application");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,7 @@ final public class JournalImpl implements Journal {
|
||||||
private ByteBufferPacketPool packetPool;
|
private ByteBufferPacketPool packetPool;
|
||||||
private long overflowNotificationTime = System.currentTimeMillis();
|
private long overflowNotificationTime = System.currentTimeMillis();
|
||||||
private Packet markPacket = new ByteArrayPacket(new byte[Location.SERIALIZED_SIZE]);
|
private Packet markPacket = new ByteArrayPacket(new byte[Location.SERIALIZED_SIZE]);
|
||||||
|
private boolean doingNotification=false;
|
||||||
|
|
||||||
public JournalImpl(File logDirectory) throws IOException {
|
public JournalImpl(File logDirectory) throws IOException {
|
||||||
this(new LogFileManager(logDirectory));
|
this(new LogFileManager(logDirectory));
|
||||||
|
@ -267,13 +268,17 @@ final public class JournalImpl implements Journal {
|
||||||
|
|
||||||
// See if we need to issue an overflow notification.
|
// See if we need to issue an overflow notification.
|
||||||
if (eventListener != null && file.isPastHalfActive()
|
if (eventListener != null && file.isPastHalfActive()
|
||||||
&& overflowNotificationTime + OVERFLOW_RENOTIFICATION_DELAY < System.currentTimeMillis()) {
|
&& overflowNotificationTime + OVERFLOW_RENOTIFICATION_DELAY < System.currentTimeMillis() && !doingNotification ) {
|
||||||
|
doingNotification = true;
|
||||||
|
try {
|
||||||
// We need to send an overflow notification to free up
|
// We need to send an overflow notification to free up
|
||||||
// some logFiles.
|
// some logFiles.
|
||||||
Location safeSpot = file.getFirstRecordLocationOfSecondActiveLogFile();
|
Location safeSpot = file.getFirstRecordLocationOfSecondActiveLogFile();
|
||||||
eventListener.overflowNotification(safeSpot);
|
eventListener.overflowNotification(safeSpot);
|
||||||
overflowNotificationTime = System.currentTimeMillis();
|
overflowNotificationTime = System.currentTimeMillis();
|
||||||
|
} finally {
|
||||||
|
doingNotification = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is it time to roll over?
|
// Is it time to roll over?
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
/**
|
||||||
|
* Copyright 2006 The Apache Software Foundation
|
||||||
|
*
|
||||||
|
* Copyright 2005 Hiram Chirino
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
package org.apache.activeio.journal.active;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version $Revision$
|
||||||
|
*/
|
||||||
|
public class JournalLockedException extends IOException {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -3696987774575855799L;
|
||||||
|
|
||||||
|
public JournalLockedException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param arg0
|
||||||
|
*/
|
||||||
|
public JournalLockedException(String arg0) {
|
||||||
|
super(arg0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -153,7 +153,7 @@ abstract public class JournalPerfToolSupport implements JournalEventListener {
|
||||||
|
|
||||||
public void overflowNotification(RecordLocation safeLocation) {
|
public void overflowNotification(RecordLocation safeLocation) {
|
||||||
try {
|
try {
|
||||||
System.out.println("Mark set: "+safeLocation);
|
// System.out.println("Mark set: "+safeLocation);
|
||||||
journal.setMark(safeLocation, false);
|
journal.setMark(safeLocation, false);
|
||||||
} catch (InvalidRecordLocationException e) {
|
} catch (InvalidRecordLocationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -30,11 +30,16 @@ import org.apache.activeio.journal.active.JournalImpl;
|
||||||
*/
|
*/
|
||||||
public class JournalPerfTool extends JournalPerfToolSupport {
|
public class JournalPerfTool extends JournalPerfToolSupport {
|
||||||
|
|
||||||
private int logFileSize = 1024*1000*5;
|
private int logFileSize = 1024*1024*50;
|
||||||
private int logFileCount = 4;
|
private int logFileCount = 4;
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
JournalPerfTool tool = new JournalPerfTool();
|
JournalPerfTool tool = new JournalPerfTool();
|
||||||
|
tool.syncFrequency=15;
|
||||||
|
tool.workerIncrement=50;
|
||||||
|
tool.workerThinkTime=0;
|
||||||
|
tool.verbose=false;
|
||||||
|
|
||||||
if( args.length > 0 ) {
|
if( args.length > 0 ) {
|
||||||
tool.journalDirectory = new File(args[0]);
|
tool.journalDirectory = new File(args[0]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue