经过多次试验,我发现根本无法使用 multinode 模块。由于 multinode 依赖于 entity-store 模块,反之亦然。 因此,将 multinode 模块包含在实体商店的Gradle配置中会导致循环依赖。
无论如何,我仍在尝试一些技巧。我发现的主要问题基本上是S3BlobVault
的创建,因为从Xodus项目外部很容易(重新)创建S3DataReaderWriterProvider
,所以主要的问题是S3BlobVault
PersistentEntityStoreImpl
的实例,这意味着它需要在S3BlobVault
之内/之内实例化(PersistentEntityStoreImpl
),由于循环依赖问题,这是不可能的。
至少我确实修改了PersistentEntityStoreImpl并添加:
public void setBlobVault(BlobVault blobVault) {
this.blobVault = blobVault;
}
然后在我的代码(应用)中,我添加了
final PersistentEntityStoreImpl store = PersistentEntityStores.newInstance(environment);
S3BlobVault s3BlobVault = createS3BlobVault(store, environment.getLocation());
store.setBlobVault(s3BlobVault);
像这样创建库:
private S3BlobVault createS3BlobVault(PersistentEntityStoreImpl store, String location) {
try {
S3AsyncClient s3 = S3AsyncClient.builder()
.credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("", "")))
.endpointOverride(new URI("https://s3.wasabisys.com"))
.region(Region.US_EAST_1).build();
S3BlobVault blobVault = null;
// Can't use code below (outside of package)
// try {
// final PersistentSequenceBlobHandleGenerator.PersistentSequenceGetter persistentSequenceGetter =
// new PersistentSequenceBlobHandleGenerator.PersistentSequenceGetter() {
// @Override
// public PersistentSequence get() {
// return getSequence(getAndCheckCurrentTransaction(), BLOB_HANDLES_SEQUENCE);
// }
// };
// blobVault = new S3BlobVault(store,
// new PersistentSequenceBlobHandleGenerator(persistentSequenceGetter), s3, "xodus", location, ".blobs", null);
// } catch (UnexpectedBlobVaultVersionException e) {
// blobVault = null;
// }
if(blobVault == null) {
blobVault = new S3BlobVault(store,
BlobHandleGenerator.IMMUTABLE, s3, "xodus", location, ".blobs", null);
}
return blobVault;
} catch (Exception e) {
throw ExodusException.toExodusException(e);
}
}
我仍然以错误结尾:
Caused by: java.io.FileNotFoundException: s3:xodus\blobs\version (The filename, directory name, or volume label syntax is incorrect)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:162)
at jetbrains.exodus.entitystore.FileSystemBlobVaultOld.<init>(FileSystemBlobVaultOld.java:106)
at jetbrains.exodus.entitystore.FileSystemBlobVaultOld.<init>(FileSystemBlobVaultOld.java:71)
at jetbrains.exodus.entitystore.PersistentEntityStoreImpl.createDefaultFSBlobVault(PersistentEntityStoreImpl.java:424)
... 95 more
答案 0 :(得分:2)
在您的项目中,您可以通过以下方式添加对多节点jar的依赖关系并创建PersitentEntityStore:
final S3BlobVault blobVault = createBlobVault(...);
final Environment env = Environments.newInstance("location");
final PersistentEntityStoreImpl store = PersistentEntityStores.newInstance(PersistentEntityStoreConfig.DEFAULT, env, blobVault, "entityStore name");
可能会起作用。至少,如果您通过blob保管库来创建PersistentEntityStore,那么您将不需要您提到的循环依赖项。 对多节点模块的依赖足以使用实体存储模块的功能。
不过,我要强调的是,多节点模块中的任何功能都不完整,未宣布,未记录且可能会发生变化。在将来的版本中可能会完全删除它。
答案 1 :(得分:1)
Xodus内部版本1.3.91共享S3功能作为实验功能。文档中没有引用,也有一些S3文件存储测试失败。我们不建议在生产代码中使用它,直到发行说明中没有提及它并且文档中没有任何部分。
目前使用S3作为Xodus的存储的结果是无法预测的。