mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-11-15 10:20:47 +00:00
Make Recorder facility usable independent of special crawler threads
* Recorder.java
store reusable per-thread Recorder instance in Recorder static thread-local
* ToeThread.java
setup reusable instance into Recorder
* RecorderMarker.java
deleted -- unnecessary
This commit is contained in:
1 parent
f35da10154
commit
248f720cab
3 files changed
+10
-52
No files matched your search
@@ -251,6 +251,13 @@ public class Recorder {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static ThreadLocal<Recorder> currentRecorder = new ThreadLocal<Recorder>();
|
||||
|
||||
public static void setHttpRecorder(Recorder httpRecorder) {
|
||||
currentRecorder.set(httpRecorder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current threads' HttpRecorder.
|
||||
*
|
||||
@@ -258,12 +265,7 @@ public class Recorder {
|
||||
* HttpRecorder in current instance.
|
||||
*/
|
||||
public static Recorder getHttpRecorder() {
|
||||
Recorder recorder = null;
|
||||
Thread thread = Thread.currentThread();
|
||||
if (thread instanceof RecorderMarker) {
|
||||
recorder = ((RecorderMarker)thread).getHttpRecorder();
|
||||
}
|
||||
return recorder;
|
||||
return currentRecorder.get();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Heritrix web crawler (crawler.archive.org).
|
||||
*
|
||||
* Licensed to the Internet Archive (IA) by one or more individual
|
||||
* contributors.
|
||||
*
|
||||
* The IA licenses this file to You 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.archive.util;
|
||||
|
||||
|
||||
/**
|
||||
* A marker interface to denote a class with a gettable HttpRecorder.
|
||||
*
|
||||
* @author stack
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface RecorderMarker
|
||||
{
|
||||
/**
|
||||
* @return An instance of HttpRecorder.
|
||||
*/
|
||||
public Recorder getHttpRecorder();
|
||||
}
|
||||
Reference in new issue
Block a user