Skip to content

Commit 29d43af

Browse files
committed
Refactor deprecated usage of Tailer
1 parent 252b4fa commit 29d43af

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

src/main/java/org/polypheny/control/control/ServiceManager.java

+26-15
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ public class ServiceManager {
9090
/**
9191
* This block restores the PolyphenyDbProcess on startup by checking the PID file. It will create a PolyphenyDbProcess
9292
* from the PID if the file contains a PID number. Then it will check if the process is still alive.
93-
*
9493
* TODO: This is maybe not required since we start a child process. By the termination of this process usually the child
9594
* processes are terminated too. However, if later on there is another way of creating the Polypheny-DB process this
9695
* static block would be more relevant (I guess).
@@ -151,7 +150,7 @@ public static boolean start( final ClientCommunicationStream clientCommunication
151150

152151

153152
public static boolean start( final ClientCommunicationStream clientCommunicationStream, final boolean startTailers ) {
154-
return start( clientCommunicationStream, true, "" );
153+
return start( clientCommunicationStream, startTailers, "" );
155154
}
156155

157156

@@ -192,10 +191,10 @@ public static boolean start( final ClientCommunicationStream clientCommunication
192191

193192
// Build list of arguments
194193
List<String> pdbArguments = new LinkedList<>();
195-
if ( pdbmsArgs.trim().length() > 0 ) {
194+
if ( !pdbmsArgs.trim().isEmpty() ) {
196195
pdbArguments.addAll( Arrays.asList( pdbmsArgs.split( " " ) ) );
197196
}
198-
if ( additionalArguments.trim().length() > 0 ) {
197+
if ( !additionalArguments.trim().isEmpty() ) {
199198
pdbArguments.addAll( Arrays.asList( additionalArguments.split( " " ) ) );
200199
}
201200
if ( configuration.getString( "pcrtl.plugins.purge" ).equals( "onStartup" ) ) {
@@ -256,21 +255,33 @@ public static boolean start( final ClientCommunicationStream clientCommunication
256255
final Logger PDB_LOGGER = LoggerFactory.getLogger( "PDB" );
257256

258257
if ( logTailer != null ) {
259-
logTailer.stop();
258+
logTailer.close();
260259
}
261260
if ( clientCommunicationStream != null ) {
262-
logTailer = new Tailer( new File( logFile ), new LogTailerListener( PDB_LOGGER::info, clientCommunicationStream::send ) );
261+
logTailer = Tailer.builder()
262+
.setFile( new File( logFile ) )
263+
.setTailerListener( new LogTailerListener( PDB_LOGGER::info, clientCommunicationStream::send ) )
264+
.get();
263265
} else {
264-
logTailer = new Tailer( new File( logFile ), new LogTailerListener( PDB_LOGGER::info ) );
266+
logTailer = Tailer.builder()
267+
.setFile( new File( logFile ) )
268+
.setTailerListener( new LogTailerListener( PDB_LOGGER::info ) )
269+
.get();
265270
}
266271

267272
if ( errTailer != null ) {
268-
errTailer.stop();
273+
errTailer.close();
269274
}
270275
if ( clientCommunicationStream != null ) {
271-
errTailer = new Tailer( new File( errFile ), new LogTailerListener( PDB_LOGGER::info, clientCommunicationStream::send ) );
276+
errTailer = Tailer.builder()
277+
.setFile( new File( errFile ) )
278+
.setTailerListener( new LogTailerListener( PDB_LOGGER::info, clientCommunicationStream::send ) )
279+
.get();
272280
} else {
273-
errTailer = new Tailer( new File( errFile ), new LogTailerListener( PDB_LOGGER::info ) );
281+
errTailer = Tailer.builder()
282+
.setFile( new File( errFile ) )
283+
.setTailerListener( new LogTailerListener( PDB_LOGGER::info ) )
284+
.get();
274285
}
275286

276287
if ( startTailers ) {
@@ -316,13 +327,13 @@ public static boolean stop( final ClientCommunicationStream clientCommunicationS
316327

317328
polyphenyDbProcess = null;
318329

319-
// Stopping std out redirectors
330+
// Stopping std out redirections
320331
if ( logTailer != null ) {
321-
logTailer.stop();
332+
logTailer.close();
322333
}
323334
logTailer = null;
324335
if ( errTailer != null ) {
325-
errTailer.stop();
336+
errTailer.close();
326337
}
327338
errTailer = null;
328339

@@ -1031,7 +1042,7 @@ public void fileNotFound() {
10311042
consumer.accept( "> !! The log file was not found. Stopping the Tailer. !!" );
10321043
}
10331044
}
1034-
this.tailer.stop();
1045+
this.tailer.close();
10351046
}
10361047

10371048

@@ -1062,7 +1073,7 @@ public void handle( Exception e ) {
10621073
for ( Consumer<String> consumer : consumers ) {
10631074
consumer.accept( "> !! Exception occurred: " + e.getMessage() + ". Stopping the Tailer. !!" );
10641075
}
1065-
this.tailer.stop();
1076+
this.tailer.close();
10661077
}
10671078
}
10681079
}

0 commit comments

Comments
 (0)