public abstract class FetchLogPiped extends FetchLog implements Callable<TaskState>
PipedOutputStream
.
Modifier and Type | Field and Description |
---|---|
private LinkedList<FetchLogEventListener> |
eventListeners
Listeners for state change events in GlassFish log fetcher.
|
private ExecutorService |
executor
ExecutorService used to run read remote server log tasks. |
private boolean |
internalExecutor
Internal
ExecutorService was used. |
(package private) static int |
LOG_REFRESH_DELAY
Log refresh delay in miliseconds.
|
private static Logger |
LOGGER
Logger instance for this class.
|
(package private) PipedOutputStream |
out
Output stream where to write retrieved remote server log.
|
(package private) static int |
PIPE_BUFFER_SIZE
Size of internal buffer in pipe input stream.
|
(package private) boolean |
taksExecute
Indicate whether log lines reading task should continue or exit.
|
(package private) Future<TaskState> |
task
Running task that reads log lines from remote server.
|
Constructor and Description |
---|
FetchLogPiped(ExecutorService executor,
GlassFishServer server,
boolean skip)
Constructs an instance of GlassFish remote server log fetcher with
external
ExecutorService . |
FetchLogPiped(GlassFishServer server,
boolean skip)
Constructs an instance of GlassFish remote server log fetcher.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(FetchLogEventListener listener)
Add GlassFish log fetcher state change listener at the end
of listeners list.
|
void |
close()
Stop log lines reading task and close input and output streams used
to access log lines received from server.
|
static FetchLogPiped |
create(ExecutorService executor,
GlassFishServer server)
Constructs an instance of GlassFish server log fetcher depending
on server being remote or local with external
ExecutorService . |
static FetchLogPiped |
create(ExecutorService executor,
GlassFishServer server,
boolean skip)
Constructs an instance of GlassFish server log fetcher depending
on server being remote or local with external
ExecutorService . |
static FetchLogPiped |
create(GlassFishServer server)
Constructs an instance of GlassFish server log fetcher depending
on server being remote or local.
|
static FetchLogPiped |
create(GlassFishServer server,
boolean skip)
Constructs an instance of GlassFish server log fetcher depending
on server being remote or local.
|
(package private) InputStream |
initInputStream()
Constructor callback which initializes log
InputStream
as PipedInputStream sending data from remote server
log reader. |
boolean |
isRunning()
Check if log lines reading task is running.
|
(package private) TaskState |
notifyListeners(TaskState state)
Notify all GlassFish log fetcher state change listeners about state
change event.
|
boolean |
removeListener(FetchLogEventListener listener)
Remove all occurrences of log fetcher state change listener
from listeners list.
|
private void |
start()
Start task.
|
private TaskState |
stop()
Stop running task if it's still running.
|
getInputStream
private static final Logger LOGGER
static final int PIPE_BUFFER_SIZE
static final int LOG_REFRESH_DELAY
final PipedOutputStream out
private ExecutorService executor
ExecutorService
used to run read remote server log tasks.private final boolean internalExecutor
ExecutorService
was used.volatile boolean taksExecute
private final LinkedList<FetchLogEventListener> eventListeners
FetchLogPiped(GlassFishServer server, boolean skip)
initInputStream
method
which initializes InputStream
as
PipedInputStream
before this constructor code is being
executed. Here we can simply connect already initialized
PipedInputStream
with newly created
PipedInputStream
.
server
- GlassFish server for fetching server log.skip
- Skip to the end of the log file.FetchLogPiped(ExecutorService executor, GlassFishServer server, boolean skip)
ExecutorService
.
Super class constructor will call initInputStream
method
which initializes InputStream
as
PipedInputStream
before this constructor code is being
executed. Here we can simply connect already initialized
PipedInputStream
with newly created
PipedInputStream
.
executor
- Executor service used to start task.server
- GlassFish server for fetching server log.skip
- Skip to the end of the log file.public static FetchLogPiped create(GlassFishServer server, boolean skip)
GlassFishServer
object.
server
- GlassFish server for fetching server log.skip
- Skip to the end of the log file.FetchLog
instance.public static FetchLogPiped create(GlassFishServer server)
GlassFishServer
object.
Log file is passed whole as is without skipping to the end.
server
- GlassFish server for fetching server log.FetchLog
instance.public static FetchLogPiped create(ExecutorService executor, GlassFishServer server, boolean skip)
ExecutorService
.
Decision if server is local or remote depends on domains folder and
domain name attributes stored in GlassFishServer
object.
executor
- Executor service used to start task.server
- GlassFish server for fetching server log.skip
- Skip to the end of the log file.FetchLog
instance.public static FetchLogPiped create(ExecutorService executor, GlassFishServer server)
ExecutorService
.
Decision if server is local or remote depends on domains folder and
domain name attributes stored in GlassFishServer
object.
Log file is passed whole as is without skipping to the end.
executor
- Executor service used to start task.server
- GlassFish server for fetching server log.FetchLog
instance.InputStream initInputStream()
InputStream
as PipedInputStream
sending data from remote server
log reader.
This initialization is called form FetchLog
super class
constructor. It already exists when FetchLogRemote
constructor is running so it may be used as argument for local
PipedOutputStream
initialization.
initInputStream
in class FetchLog
PipedInputStream
where log lines received from server
will be available to read.public final void addListener(FetchLogEventListener listener) throws FetchLogException
listener
- Listener for state change events in GlassFish log fetcher
to be added. Value shall not be null
.FetchLogException
- When listener
parameter
is null
.public final boolean removeListener(FetchLogEventListener listener) throws FetchLogException
listener
- Listener for state change events in GlassFish log fetcher
to be removed. Value shall not be null
.true
when at least one listener was removed
or false
otherwise.FetchLogException
- When listener
parameter
is null
.final TaskState notifyListeners(TaskState state)
state
- Current GlassFish log fetcher state.private void start()
private TaskState stop()
public void close()
public boolean isRunning()
true
when task is still running
or false>
otherwise.Copyright © 2013. All Rights Reserved.