Search in sources :

Example 6 with LogNotFoundException

use of org.apache.distributedlog.exceptions.LogNotFoundException in project bookkeeper by apache.

the class DLFileSystem method listStatus.

@Override
public FileStatus[] listStatus(Path path) throws FileNotFoundException, IOException {
    String logName = getStreamName(path);
    try {
        Iterator<String> logs = namespace.getLogs(logName);
        List<FileStatus> statusList = Lists.newArrayList();
        while (logs.hasNext()) {
            String child = logs.next();
            Path childPath = new Path(path, child);
            statusList.add(getFileStatus(childPath));
        }
        Collections.sort(statusList, Comparator.comparing(fileStatus -> fileStatus.getPath().getName()));
        return statusList.toArray(new FileStatus[statusList.size()]);
    } catch (LogNotFoundException e) {
        throw new FileNotFoundException(path.toString());
    }
}
Also used : Path(org.apache.hadoop.fs.Path) Progressable(org.apache.hadoop.util.Progressable) FileSystem(org.apache.hadoop.fs.FileSystem) DistributedLogManager(org.apache.distributedlog.api.DistributedLogManager) BufferedFSInputStream(org.apache.hadoop.fs.BufferedFSInputStream) LogNotFoundException(org.apache.distributedlog.exceptions.LogNotFoundException) FileStatus(org.apache.hadoop.fs.FileStatus) FsPermission(org.apache.hadoop.fs.permission.FsPermission) BufferedOutputStream(java.io.BufferedOutputStream) InetAddress(java.net.InetAddress) FSDataOutputStream(org.apache.hadoop.fs.FSDataOutputStream) Lists(com.google.common.collect.Lists) LogReader(org.apache.distributedlog.api.LogReader) DistributedLogConfiguration(org.apache.distributedlog.DistributedLogConfiguration) NamespaceBuilder(org.apache.distributedlog.api.namespace.NamespaceBuilder) Configuration(org.apache.hadoop.conf.Configuration) DLSN(org.apache.distributedlog.DLSN) Utils(org.apache.distributedlog.util.Utils) Path(org.apache.hadoop.fs.Path) URI(java.net.URI) DistributedLogConstants(org.apache.distributedlog.DistributedLogConstants) FSDataInputStream(org.apache.hadoop.fs.FSDataInputStream) Iterator(java.util.Iterator) IOException(java.io.IOException) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) Namespace(org.apache.distributedlog.api.namespace.Namespace) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) LogEmptyException(org.apache.distributedlog.exceptions.LogEmptyException) AsyncLogWriter(org.apache.distributedlog.api.AsyncLogWriter) Optional(java.util.Optional) Comparator(java.util.Comparator) Collections(java.util.Collections) ConfigurationException(org.apache.commons.configuration.ConfigurationException) FileStatus(org.apache.hadoop.fs.FileStatus) FileNotFoundException(java.io.FileNotFoundException) LogNotFoundException(org.apache.distributedlog.exceptions.LogNotFoundException)

Example 7 with LogNotFoundException

use of org.apache.distributedlog.exceptions.LogNotFoundException in project bookkeeper by apache.

the class DLFileSystem method open.

@Override
public FSDataInputStream open(Path path, int bufferSize) throws IOException {
    try {
        DistributedLogManager dlm = namespace.openLog(getStreamName(path));
        LogReader reader;
        try {
            reader = dlm.openLogReader(DLSN.InitialDLSN);
        } catch (LogNotFoundException lnfe) {
            throw new FileNotFoundException(path.toString());
        } catch (LogEmptyException lee) {
            throw new FileNotFoundException(path.toString());
        }
        return new FSDataInputStream(new BufferedFSInputStream(new DLInputStream(dlm, reader, 0L), bufferSize));
    } catch (LogNotFoundException e) {
        throw new FileNotFoundException(path.toString());
    }
}
Also used : LogEmptyException(org.apache.distributedlog.exceptions.LogEmptyException) BufferedFSInputStream(org.apache.hadoop.fs.BufferedFSInputStream) DistributedLogManager(org.apache.distributedlog.api.DistributedLogManager) LogReader(org.apache.distributedlog.api.LogReader) FileNotFoundException(java.io.FileNotFoundException) FSDataInputStream(org.apache.hadoop.fs.FSDataInputStream) LogNotFoundException(org.apache.distributedlog.exceptions.LogNotFoundException)

Example 8 with LogNotFoundException

use of org.apache.distributedlog.exceptions.LogNotFoundException in project bookkeeper by apache.

the class AbstractStateStoreWithJournal method getLastDLSN.

private CompletableFuture<DLSN> getLastDLSN(StateStoreSpec spec) {
    synchronized (this) {
        if (null != closeFuture) {
            return FutureUtils.exception(new StateStoreClosedException(name()));
        }
    }
    try {
        logManager = logNamespace.openLog(spec.getStream());
    } catch (IOException e) {
        return FutureUtils.exception(e);
    }
    CompletableFuture<DLSN> future = FutureUtils.createFuture();
    logManager.getLastDLSNAsync().whenCompleteAsync(new FutureEventListener<DLSN>() {

        @Override
        public void onSuccess(DLSN dlsn) {
            future.complete(dlsn);
        }

        @Override
        public void onFailure(Throwable throwable) {
            if (throwable instanceof LogEmptyException || throwable instanceof LogNotFoundException) {
                FutureUtils.proxyTo(writeCatchUpMarker(), future);
            } else {
                future.completeExceptionally(throwable);
            }
        }
    });
    return future;
}
Also used : LogEmptyException(org.apache.distributedlog.exceptions.LogEmptyException) StateStoreClosedException(org.apache.bookkeeper.statelib.api.exceptions.StateStoreClosedException) LogRecordWithDLSN(org.apache.distributedlog.LogRecordWithDLSN) DLSN(org.apache.distributedlog.DLSN) IOException(java.io.IOException) LogNotFoundException(org.apache.distributedlog.exceptions.LogNotFoundException)

Example 9 with LogNotFoundException

use of org.apache.distributedlog.exceptions.LogNotFoundException in project bookkeeper by apache.

the class BKDistributedLogNamespace method deleteLog.

@Override
public void deleteLog(String logName) throws InvalidStreamNameException, LogNotFoundException, IOException {
    checkState();
    logName = validateAndNormalizeName(logName);
    com.google.common.base.Optional<URI> uri = Utils.ioResult(driver.getLogMetadataStore().getLogLocation(logName));
    if (!uri.isPresent()) {
        throw new LogNotFoundException("Log " + logName + " isn't found.");
    }
    DistributedLogManager dlm = openLogInternal(uri.get(), logName, Optional.empty(), Optional.empty());
    dlm.delete();
}
Also used : DistributedLogManager(org.apache.distributedlog.api.DistributedLogManager) LogNotFoundException(org.apache.distributedlog.exceptions.LogNotFoundException) URI(java.net.URI)

Example 10 with LogNotFoundException

use of org.apache.distributedlog.exceptions.LogNotFoundException in project bookkeeper by apache.

the class BKDistributedLogNamespace method renameLog.

@Override
public CompletableFuture<Void> renameLog(String oldName, String newName) {
    try {
        checkState();
        final String oldLogName = validateAndNormalizeName(oldName);
        final String newLogName = validateAndNormalizeName(newName);
        return driver.getLogMetadataStore().getLogLocation(oldName).thenCompose(uriOptional -> {
            if (uriOptional.isPresent()) {
                return driver.getLogStreamMetadataStore(WRITER).renameLog(uriOptional.get(), oldLogName, newLogName);
            } else {
                return FutureUtils.exception(new LogNotFoundException("Log " + oldLogName + " isn't found."));
            }
        });
    } catch (IOException ioe) {
        return FutureUtils.exception(ioe);
    }
}
Also used : LogNotFoundException(org.apache.distributedlog.exceptions.LogNotFoundException) IOException(java.io.IOException)

Aggregations

LogNotFoundException (org.apache.distributedlog.exceptions.LogNotFoundException)17 DistributedLogManager (org.apache.distributedlog.api.DistributedLogManager)8 FileNotFoundException (java.io.FileNotFoundException)4 IOException (java.io.IOException)4 LogReader (org.apache.distributedlog.api.LogReader)4 DLInterruptedException (org.apache.distributedlog.exceptions.DLInterruptedException)4 LogEmptyException (org.apache.distributedlog.exceptions.LogEmptyException)4 List (java.util.List)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 ZooKeeperConnectionException (org.apache.distributedlog.ZooKeeperClient.ZooKeeperConnectionException)3 ZKException (org.apache.distributedlog.exceptions.ZKException)3 BufferedOutputStream (java.io.BufferedOutputStream)2 URI (java.net.URI)2 LinkedList (java.util.LinkedList)2 DLSN (org.apache.distributedlog.DLSN)2 ZooKeeperClient (org.apache.distributedlog.ZooKeeperClient)2 AsyncLogWriter (org.apache.distributedlog.api.AsyncLogWriter)2 DLIllegalStateException (org.apache.distributedlog.exceptions.DLIllegalStateException)2 BufferedFSInputStream (org.apache.hadoop.fs.BufferedFSInputStream)2 FSDataInputStream (org.apache.hadoop.fs.FSDataInputStream)2