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());
}
}
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());
}
}
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;
}
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();
}
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);
}
}
Aggregations