public class LogCopier extends AbstractScheduledService
FileSystems.
This class extends the AbstractScheduledService so it can be used with a
ServiceManager that manages the lifecycle of
a LogCopier.
This class is intended to be used in the following pattern:
LogCopier.Builder logCopierBuilder = LogCopier.newBuilder();
LogCopier logCopier = logCopierBuilder
.useSrcFileSystem(FileSystem.getLocal(new Configuration()))
.useDestFileSystem(FileSystem.get(URI.create(destFsUri), new Configuration()))
.readFrom(new Path(srcLogDir))
.writeTo(new Path(destLogDir))
.useInitialDelay(60)
.useCopyInterval(60)
.useMaxMinutesPerLogFile(60)
.useMaxBytesPerLogFile(1024 * 1024)
.useTimeUnit(TimeUnit.SECONDS)
.build();
ServiceManager serviceManager = new ServiceManager(Lists.newArrayList(logCopier));
serviceManager.startAsync();
// ...
serviceManager.stopAsync().awaitStopped(60, TimeUnit.SECONDS);
Checkout the Javadoc of LogCopier.Builder to see the available options for customization.
| Modifier and Type | Class and Description |
|---|---|
static class |
LogCopier.Builder
A builder class for
LogCopier. |
AbstractScheduledService.CustomScheduler, AbstractScheduledService.SchedulerService.Listener, Service.State| Modifier and Type | Method and Description |
|---|---|
static LogCopier.Builder |
newBuilder()
Get a new
LogCopier.Builder instance for building a LogCopier. |
protected void |
runOneIteration() |
protected AbstractScheduledService.Scheduler |
scheduler() |
protected void |
shutDown() |
addListener, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, executor, failureCause, isRunning, serviceName, start, startAndWait, startAsync, startUp, state, stop, stopAndWait, stopAsync, toStringprotected void shutDown()
throws Exception
shutDown in class AbstractScheduledServiceExceptionprotected void runOneIteration()
throws IOException
runOneIteration in class AbstractScheduledServiceIOExceptionprotected AbstractScheduledService.Scheduler scheduler()
scheduler in class AbstractScheduledServicepublic static LogCopier.Builder newBuilder()
LogCopier.Builder instance for building a LogCopier.LogCopier.Builder instance