don't throw exceptions from ctor, guice is hell
This commit is contained in:
parent
f174e96a14
commit
3269beeb4d
|
@ -55,25 +55,37 @@ public class HdfsRepository extends BlobStoreRepository implements FileContextFa
|
|||
|
||||
public final static String TYPE = "hdfs";
|
||||
|
||||
private final HdfsBlobStore blobStore;
|
||||
private final BlobPath basePath;
|
||||
private final ByteSizeValue chunkSize;
|
||||
private final boolean compress;
|
||||
private final RepositorySettings repositorySettings;
|
||||
private final ThreadPool threadPool;
|
||||
private final String path;
|
||||
private FileContext fc;
|
||||
private HdfsBlobStore blobStore;
|
||||
|
||||
@Inject
|
||||
public HdfsRepository(RepositoryName name, RepositorySettings repositorySettings, IndexShardRepository indexShardRepository, ThreadPool threadPool) throws IOException {
|
||||
super(name.getName(), repositorySettings, indexShardRepository);
|
||||
|
||||
this.repositorySettings = repositorySettings;
|
||||
this.threadPool = threadPool;
|
||||
|
||||
String path = repositorySettings.settings().get("path", settings.get("path"));
|
||||
path = repositorySettings.settings().get("path", settings.get("path"));
|
||||
|
||||
|
||||
this.basePath = BlobPath.cleanPath();
|
||||
this.chunkSize = repositorySettings.settings().getAsBytesSize("chunk_size", settings.getAsBytesSize("chunk_size", null));
|
||||
this.compress = repositorySettings.settings().getAsBoolean("compress", settings.getAsBoolean("compress", false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() {
|
||||
// get configuration
|
||||
if (path == null) {
|
||||
throw new IllegalArgumentException("no 'path' defined for hdfs snapshot/restore");
|
||||
}
|
||||
|
||||
// get configuration
|
||||
try {
|
||||
fc = getFileContext();
|
||||
Path hdfsPath = SecurityUtils.execute(fc, new FcCallback<Path>() {
|
||||
@Override
|
||||
|
@ -81,12 +93,12 @@ public class HdfsRepository extends BlobStoreRepository implements FileContextFa
|
|||
return fc.makeQualified(new Path(path));
|
||||
}
|
||||
});
|
||||
this.basePath = BlobPath.cleanPath();
|
||||
|
||||
logger.debug("Using file-system [{}] for URI [{}], path [{}]", fc.getDefaultFileSystem(), fc.getDefaultFileSystem().getUri(), hdfsPath);
|
||||
blobStore = new HdfsBlobStore(settings, this, hdfsPath, threadPool);
|
||||
this.chunkSize = repositorySettings.settings().getAsBytesSize("chunk_size", settings.getAsBytesSize("chunk_size", null));
|
||||
this.compress = repositorySettings.settings().getAsBoolean("compress", settings.getAsBoolean("compress", false));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
super.doStart();
|
||||
}
|
||||
|
||||
// as the FileSystem is long-lived and might go away, make sure to check it before it's being used.
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
body:
|
||||
type: hdfs
|
||||
settings:
|
||||
uri: "hdfs://localhost:36909"
|
||||
uri: "hdfs://localhost:40737"
|
||||
path: "foo/bar"
|
||||
|
||||
# Get repository
|
||||
|
|
|
@ -12,7 +12,7 @@ setup:
|
|||
body:
|
||||
type: hdfs
|
||||
settings:
|
||||
uri: "hdfs://localhost:36909"
|
||||
uri: "hdfs://localhost:40737"
|
||||
path: "foo/bar"
|
||||
|
||||
- do:
|
||||
|
|
|
@ -12,7 +12,7 @@ setup:
|
|||
body:
|
||||
type: hdfs
|
||||
settings:
|
||||
uri: "hdfs://localhost:36909"
|
||||
uri: "hdfs://localhost:40737"
|
||||
path: "foo/bar"
|
||||
|
||||
- do:
|
||||
|
|
Loading…
Reference in New Issue