The English version of quarkus.io is the official project site. Translated sites are community supported on a best-effort basis.

Infinispanクライアント

Infinispanは分散型のインメモリキー/バリューストアで、Quarkusアプリケーションに、高度に設定可能で独立して拡張可能なデータレイヤーを提供します。 このエクステンションにより、Quarkus上で動作するアプリケーションをリモートのInfinispanクラスタと接続するクライアント機能が提供されます。

Infinispanの詳細については、 Infinispanのドキュメントをご覧ください。

ソリューション

アプリケーションを作成するには、以下のセクションの各ステップを完了することをお勧めします。ただし、以下のように、完成したソリューションを直接利用することもできます:

Git リポジトリをクローンします。 git clone https://github.com/quarkusio/quarkus-quickstarts.git または アーカイブをダウンロードします。 infinispan-client-quickstart ディレクトリでソリューションを探します。

Infinispanクライアントエクステンションの追加

Quarkusプロジェクトのベースディレクトリで以下のコマンドを実行し、 infinispan-client エクステンションを追加します:

コマンドラインインタフェース
quarkus extension add 'infinispan-client'
Maven
./mvnw quarkus:add-extension -Dextensions='infinispan-client'
Gradle
./gradlew addExtension --extensions='infinispan-client'

このコマンドは、ビルドファイルに以下の依存関係を追加します:

pom.xml
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-infinispan-client</artifactId>
</dependency>
build.gradle
implementation 'io.quarkus:quarkus-infinispan-client'
annotationProcessor 'org.infinispan.protostream:protostream-processor:4.5.1.Final' (1)
1 アノテーションベースのシリアライゼーションでファイル生成を有効にするため、Gradleビルドで必須

Infinispanクライアントの設定

src/main/resources ディレクトリの application.properties をテキストエディタで開いて下さい。

Infinispanのドキュメントでは、 hotrod-client.properties のファイルを参照していることに注意してください。どちらのプロパティ・ファイルでもInfinispanクライアントを設定できますが、 application.properties は常に hotrod-client.properties よりも優先されます。

さらに、実行時にコンフィギュレーションプロパティを更新することはできません。 もし、 application.propertieshotrod-client.properties を変更した場合、その変更を反映させる前にアプリケーションをリビルドしなければなりません。

Infinispanクラスタへの接続

Infinispan Serverを起動している場合、以下のプロパティを追加して接続します。

quarkus.infinispan-client.hosts=localhost:11222 (1)

quarkus.infinispan-client.username=admin (2)
quarkus.infinispan-client.password=password (3)

quarkus.infinispan-client.client-intelligence=BASIC (4)
1 Infinispanサーバーのアドレスリストをカンマ区切りで設定します。
2 認証ユーザー名を設定
3 認証パスワードを設定
4 クライアントのインテリジェンスを設定。Docker for Macを使用する場合は、BASICを回避策として使用します。

または、単一の接続プロパティを指定することで、uri接続を使用することもできます。

quarkus.infinispan-client.uri=hotrod://admin:password@localhost:11222 (1)
quarkus.infinispan-client.client-intelligence=BASIC (2)
1 InfinispanのURI接続を設定します。以下のプロパティは無視されます: hosts、username、password。
2 クライアントのインテリジェンスを設定します。Docker for Macを使用する場合は、BASICをワークアラウンドとして使用します。

Infinispan Dev Services を使用してサーバーを実行し、設定なしで接続します。

Infinispanサーバの起動

Infinispanクライアント・エクステンションを使用するには、少なくとも1つのInfinispan Serverの稼働しているインスタンスが必要です。

Infinispan Serverをローカルで実行するための5分間のチュートリアル Getting stated with Infinispanをご覧ください。

また、Infinispan Serverはデフォルトで認証とセキュリティの認可を有効にしているので、権限のあるユーザーを作成する必要があります。

  • Infinispan Server イメージを実行する場合は、 USER="admin"PASS="password" のパラメータを渡します。

  • ベアメタル・ディストリビューションを実行する場合は、次のようにコマンドライン・インターフェース(CLI)を使用します:

    $ ./bin/cli.sh user create admin -p password

Infinispan ヘルス・チェック

quarkus-smallrye-health エクステンションを使用している場合、Infinispan クライアントエクステンションは、接続を検証するためのReadinessヘルスチェックを自動的に追加します。

アプリケーションの /q/health/ready エンドポイントにアクセスすると、サーバー接続と利用可能なキャッシュの情報が表示されます。

この動作は、プロパティ quarkus.infinispan-client.health.enabled で無効にすることができます。

クライアントからキャッシュを作成

クライアントからキャッシュにアクセスする際、Infinispan Server内にキャッシュが存在せず、初回アクセス時にキャッシュを作成したい場合は、以下のいずれかのプロパティを使用します。

quarkus.infinispan-client.cache.books.configuration-uri=cacheConfig.json (1)
quarkus.infinispan-client.cache.magazine.configuration=<distributed-cache><encoding media-type="application/x-protostream"/></distributed-cache> (2)
1 books’キャッシュの設定を含む resources フォルダー下のファイル名
2 プレーンテキストプロパティとして 'magazine' キャッシュの設定

configuration-uriconfiguration の両方が同じ Quarkus プロファイルで同じキャッシュに設定されている場合、 configuration-uriconfiguration より優先されます。

キャッシュ設定は、XML、JSON、または YAML で提供することができます。Infinispan コンソールおよびキャッシュ設定ウィザードを使用して、Infinispan キャッシュの詳細について学び、ガイド付きの設定を作成してください。

特定のキャッシュについて何も設定されていない場合、以下の基本設定で作成されます。

XML
<distributed-cache>
    <encoding media-type="application/x-protostream"/>
</distributed-cache>
JSON
{
    "distributed-cache": {
        "encoding": {
            "media-type": "application/x-protostream"
        }
    }
}
YAML
distributedCache:
  encoding:
    mediaType: "application/x-protostream"

認証メカニズム

Infinispanクライアントでは、以下の認証メカニズムを使用することができます:

  • DIGEST-MD5

  • PLAIN(TLS暗号化との併用のみ推奨)

  • EXTERNAL

SCRAMやGSSAPIなどの他の認証メカニズムは、Infinispanクライアントではまだ検証されていません。

認証の設定についての詳しい情報は Hot Rod Endpoint Authentication Mechanisms に存在します。

Dependency Injectionを使用する場合は、 hotrod-client.properties ファイルで認証の設定を行う必要があります。

シリアライゼーション(Key Value型のサポート)

デフォルトでは、クライアントは以下の型のキーとバリューをサポートします: byte[]、プリミティブラッパー(例: Integer、Long、Doubleなど)、String、Date、Instant。ユーザ型については、ここで詳しく説明される追加のステップが必要です。以下のようなユーザクラスがあるとします:

Author.java
public class Author {
   private final String name;
   private final String surname;

   public Author(String name, String surname) {
      this.name = Objects.requireNonNull(name);
      this.surname = Objects.requireNonNull(surname);
   }
   // Getter/Setter/equals/hashCode/toString omitted
}
Book.java
public class Book {
   private final String title;
   private final String description;
   private final int publicationYear;
   private final Set<Author> authors;
   private final BigDecimal price;

   public Book(String title, String description, int publicationYear, Set<Author> authors, BigDecimal price) {
      this.title = Objects.requireNonNull(title);
      this.description = Objects.requireNonNull(description);
      this.publicationYear = publicationYear;
      this.authors = Objects.requireNonNull(authors);
      this.price = price;
   }
   // Getter/Setter/equals/hashCode/toString omitted
}

ユーザ型のシリアライズは、 Protostreamと呼ばれるprotobufをベースにしたライブラリを使用します。

Infinispanのキャッシュは、さまざまなエンコーディングでキーと値を保存できますが、 プロトコル・バッファ(Protobuf) の使用を推奨します。

詳しくは、 Cache Encoding and Marshalling ガイドをご覧ください。

アノテーションに基づくシリアライゼーション

これは、ユーザクラスに protostream アノテーションを追加することで自動的に行えます。加えて、初期化子がアノテーションされたインターフェースが1つ必要です。これは、サポートするクラスの生成方法を制御します。

ここでは、先述のクラスをどのように変更するかの例を示します。

Author.java
    @ProtoFactory
    public Author(String name, String surname) {
        this.name = Objects.requireNonNull(name);
        this.surname = Objects.requireNonNull(surname);
    }

    @ProtoField(number = 1)
    public String getName() {
        return name;
    }

    @ProtoField(number = 2)
    public String getSurname() {
        return surname;
    }
Book.java
    @ProtoFactory
    public Book(String title, String description, int publicationYear, Set<Author> authors) {
        this.title = Objects.requireNonNull(title);
        this.description = Objects.requireNonNull(description);
        this.publicationYear = publicationYear;
        this.authors = Objects.requireNonNull(authors);
    }

    @ProtoField(number = 1)
    public String getTitle() {
        return title;
    }

    @ProtoField(number = 2)
    public String getDescription() {
        return description;
    }

    @ProtoField(number = 3, defaultValue = "-1")
    public int getPublicationYear() {
        return publicationYear;
    }

    @ProtoField(number = 4)
    public Set<Author> getAuthors() {
        return authors;
    }

クラスが変更可能なフィールドしかない場合、 ProtoFactory アノテーションは必要ありません。あなたのクラスが引数なしのコンストラクタを持っていると仮定します。

必要なのは、設定を指定する為のアノテーションを付与した非常にシンプルな GeneratedSchema インターフェイスだけです。

BooksSchema.java
import org.infinispan.protostream.GeneratedSchema;
import org.infinispan.protostream.annotations.AutoProtoSchemaBuilder;
import org.infinispan.protostream.types.java.math.BigDecimalAdapter;

@AutoProtoSchemaBuilder(includeClasses = { Book.class, Author.class, BigDecimalAdapter.class }, schemaPackageName = "book_sample")
interface BookStoreSchema extends GeneratedSchema {
}

Protostream は、 org.infinispan.protostream.types パッケージに含まれる BigDecimal のように、一般的に使用される型に対するデフォルトの Protobuf マッパーが提供します。

そこで今回は、含まれるクラスのマーシャラーとスキーマを自動生成して、スキーマパッケージに自動で配置します。パッケージは用意する必要はありませんが、Infinispan検索機能を利用する場合は生成されたパッケージを知っておく必要があります。

Quarkusでは、 schemaFileNameschemaFilePath 属性は、 AutoProtoSchemaBuilder アノテーションに設定すべきではありません。いずれかを設定すると、ネイティブランタイムエラーが発生します。

カスタムシリアライゼーション

前の方法は、ユーザが自分のクラスにアノテーションを付けられる場合のために提案されています。残念ながら、ユーザはキャッシュに入れるすべてのクラスにアノテーションを付けることができないかもしれません。このような場合はスキーマを定義し、自分で独自のマーシャラを作成しなければなりません。

Protobuf スキーマ

2つの方法のいずれかでprotobufスキーマを提供できます。

  1. Proto ファイル
    プロジェクトの META-INF ディレクトリに .proto ファイルを置くことができます。これらのファイルは初期化時に自動的にピックアップされます。

    library.proto
    package book_sample;
    
    message Book {
      required string title = 1;
      required string description = 2;
      required int32 publicationYear = 3; // no native Date type available in Protobuf
      repeated Author authors = 4;
      requited double price = 5; // no native BigDecimal type available in Protobuf
    }
    
    message Author {
      required string name = 1;
      required string surname = 2;
    }
  2. コード内
    または、 org.infinispan.protostream.FileDescriptorSource 型のプロデュースされた Bean を定義することで、ユーザーコード内で直接プロトスキーマを定義することもできます。

       @Produces
       FileDescriptorSource bookProtoDefinition() {
          return FileDescriptorSource.fromString("library.proto", "package book_sample;\n" +
                "\n" +
                "message Book {\n" +
                "  required string title = 1;\n" +
                "  required string description = 2;\n" +
                "  required int32 publicationYear = 3; // no native Date type available in Protobuf\n" +
                "\n" +
                "  repeated Author authors = 4;\n" +
                "\n" +
                "  required double price = 5; // no native BigDecimal type available in Protobuf\n" +
                "}\n" +
                "\n" +
                "message Author {\n" +
                "  required string name = 1;\n" +
                "  required string surname = 2;\n" +
                "}");
       }
ユーザマーシャラ

最後にすべきことは、proto スキーマで定義された各ユーザクラスの org.infinispan.protostream.MessageMarshaller 実装を提供することです。このクラスは、上記のコードベースの proto スキーマの定義と同様の方法で @Produces を介して提供されます。

こちらは、Author と Book クラスのマーシャラクラスです。

型名は <protobuf package>.<protobuf message> と正確に一致している必要があります!
AuthorMarshaller.java
public class AuthorMarshaller implements MessageMarshaller<Author> {

   @Override
   public String getTypeName() {
      return "book_sample.Author";
   }

   @Override
   public Class<? extends Author> getJavaClass() {
      return Author.class;
   }

   @Override
   public void writeTo(ProtoStreamWriter writer, Author author) throws IOException {
      writer.writeString("name", author.getName());
      writer.writeString("surname", author.getSurname());
   }

   @Override
   public Author readFrom(ProtoStreamReader reader) throws IOException {
      String name = reader.readString("name");
      String surname = reader.readString("surname");
      return new Author(name, surname);
   }
}
BookMarshaller.java
public class BookMarshaller implements MessageMarshaller<Book> {

   @Override
   public String getTypeName() {
      return "book_sample.Book";
   }

   @Override
   public Class<? extends Book> getJavaClass() {
      return Book.class;
   }

   @Override
   public void writeTo(ProtoStreamWriter writer, Book book) throws IOException {
      writer.writeString("title", book.getTitle());
      writer.writeString("description", book.getDescription());
      writer.writeInt("publicationYear", book.getPublicationYear());
      writer.writeCollection("authors", book.getAuthors(), Author.class);
      writer.writeDouble("price", book.getPrice().doubleValue());
   }

   @Override
   public Book readFrom(ProtoStreamReader reader) throws IOException {
      String title = reader.readString("title");
      String description = reader.readString("description");
      int publicationYear = reader.readInt("publicationYear");
      Set<Author> authors = reader.readCollection("authors", new HashSet<>(), Author.class);
      BigDecimal price = BigDecimal.valueOf(reader.readDouble("price"));
      return new Book(title, description, publicationYear, authors, price);
   }
}

そして、以下のように定義してマーシャラを渡します。

   @Produces
   MessageMarshaller authorMarshaller() {
      return new AuthorMarshaller();
   }

   @Produces
   MessageMarshaller bookMarshaller() {
      return new BookMarshaller();
   }
上記のように生成されたMarshallerメソッドは、型なしで MessageMarshaller を返さなければなりません。さもないと、それが見つかりません。

依存性注入

上で見たように、私たちはユーザーが Marshaller のコンフィギュレーションをインジェクションすることをサポートしています。Infinispan クライアントエクステンションでは、 RemoteCacheManagerRemoteCache オブジェクトへのインジェクションを提供し、その逆を行うことができます。 グローバルな RemoteCacheManager が一つあり、上記のセクションで設定したすべてのコンフィギュレーションパラメータを受け取ります。

これらのコンポーネントをインジェクトするのは非常に簡単です。必要なのは、フィールド、コンストラクタ、またはメソッドに @Inject アノテーションを追加することだけです。以下のコードでは、フィールドとコンストラクタのインジェクションを利用しています。

SomeClass.java
    @Inject SomeClass(RemoteCacheManager remoteCacheManager) {
       this.remoteCacheManager = remoteCacheManager;
    }

    @Inject
    @Remote("myCache")
    RemoteCache<String, Book> cache;

    RemoteCacheManager remoteCacheManager;

RemoteCache 宣言に Remote というオプションのアノテーションが追加されていることにお気づきでしょうか。これは、注入される名前付きキャッシュを指定するための修飾子アノテーションです。このアノテーションは必須ではなく、指定しなかった場合はデフォルトのキャッシュが注入されます。

その他の型は注入のためにサポートされている場合がありますが、詳細については他のセクションを参照してください。

InfinispanサーバへのProtobufスキーマの登録

クエリを実行したり、 Protobuf から JSON のような他のメディアタイプに変換するには、生成された Protobuf スキーマを Infinispan Server に登録する必要があります。

Infinispan コンソールにログインして http://localhost:11222 にアクセスすると、 Schemas タブに存在するスキーマを確認することができます

デフォルトでは、この方法で生成されたProtobufスキーマは、クライアントが最初に接続したときに、このエクステンションによって登録されます。 しかし、実運用で使用しているとスキーマが時間の経過とともに進化する可能性があるため、手動で登録を処理する必要があるかもしれません。そのため、 quarkus.infinispan-client.use-schema-registrationfalse に設定して、この現象を無効にすることができます。

スキーマを手動で設定するには、Kubernetes デプロイメント用の Infinispan Operator 、Infinispan Console、 REST API または Hot Rod Java Client を使用してください。

アノテーションを利用したキャッシング

Infinispan Client エクステンションは、Infinispan でのキャッシュ能力を有効にするために CDI 管理 Bean で使用できるアノテーションのセットを提供します。

プライベートメソッドではアノテーションのキャッシュは許可されていません。package-private (明示的な修飾子を持たない) を含む他のアクセス修飾子では問題なく動作します。

@CacheResult

可能な限り、メソッド本体を実行せずにキャッシュからメソッドの結果を読み込みます。

@CacheResult でアノテーションされたメソッドが呼び出されると、Quarkus はメソッドの引数をキャッシュキーとして使用し、そのメソッドがすでに呼び出されているかどうかをキャッシュでチェックします。複数のパラメータを持つメソッドは許可されません。複合キーの場合は、複数の値を保持するProtobufスキーマを定義します。キャッシュ内に値が見つかった場合、その値を返し、アノテーションされたメソッドは実際に実行されることはありません。値が見つからない場合、アノテーションされたメソッドが呼び出され、返された値は計算されたキーを使用してキャッシュに格納されます。このアノテーションは、 void を返すメソッドには使用できません。

Infinispan Client エクステンションは、Quarkus-Cache エクステンションとは異なり、まだ null 値をキャッシュすることができません。

@CacheInvalidate

キャッシュからエントリーを削除します。

@CacheInvalidate でアノテーションされたメソッドが呼び出されると、 Infinispan はメソッドの引数をキャッシュキーとして使用し、 キャッシュから既存のエントリを削除しようとします。キーがキャッシュエントリーを特定できない場合、何も起こりません。

@CacheInvalidateAll

@CacheInvalidateAll でアノテーションされたメソッドが呼び出されると、Infinispan はキャッシュからすべてのエントリを削除します。

問い合わせ

Infinispan クライアントは、上記の ProtoStreamMarshaller が設定されている限り、インデックス付と非インデックス付の両方の検索をサポートしています。これにより、ユーザはプロトスキーマのプロパティに基づいてクエリできます。パフォーマンス上の理由から、インデックス付クエリが望ましいです

XML
<distributed-cache name="books" statistics="true">
    <!-- other configuration -->
	<indexing enabled="true" storage="filesystem" startup-mode="PURGE">
		<indexed-entities>
			<indexed-entity>book_sample.Book</indexed-entity>
		</indexed-entities>
	</indexing>
</distributed-cache>
JSON
{
  "books": {
    "distributed-cache": {
      ...
      "indexing": {
        "enabled": true,
        "storage": "filesystem",
        "startupMode": "PURGE",
        "indexed-entities": [
          "book_sample.Book"
        ]
      }
    }
  }
}
YAML
distributedCache:
  # other configuration
  indexing:
    enabled: "true"
    storage: "filesystem"
    startupMode: "PURGE"
    indexedEntities:
      - "book_sample.Book"

Query は、 ProtoStreamMarshaller の設定時に設定できるproto定義に基づいて構築されます。上記のいずれのシリアライズ方法でも、起動時に自動的にスキーマをサーバに登録し、リモートの Infinispan サーバーに保存されているオブジェクトを問い合せる機能を自動的に得られます。

Book.java
@Indexed (1)
public class Book {

    @ProtoFactory
    public Book(String title, String description, int publicationYear, Set<Author> authors) {
      ...
    }

    @ProtoField(number = 1)
    @Text (2)
    public String getTitle() {
        return title;
    }

    @ProtoField(number = 2)
    @Keyword(projectable = true, sortable = true, normalizer = "lowercase", indexNullAs = "unnamed", norms = false) (3)
    public String getDescription() {
        return description;
    }
    ...
1 @Indexed アノテーションは、POJOをインデックス可能にします
2 @Basic アノテーションは、インデックス付きフィールドに対して特別な変換を行わずに使用されます。
3 @Keyword アノテーションは、テキストフィールドにnormalizer を適用するために使用します。

Quarkus Infinispanクライアントエクステンションでは、Query DSLまたはIckle Query 言語のいずれかを使用できます。

詳細は Infinispan のドキュメントの クエリ を参照してください。

カウンター

Infinispanにはカウンターという概念もあり、Quarkus Infinispanのクライアントはそれらもサポートしています。

Quarkus Infinispan クライアントエクステンションでは、 CounterManager を直接依存性注入することができます。フィールド、コンストラクタ、メソッドにアノテーションを付けるだけで、簡単に取得できます。そして、通常と同じようにカウンタを使用することができます。

@Inject
CounterManager counterManager;

詳細は Infinispan のドキュメント クラスタカウンタ を参照してください。

ニアキャッシング

ニアキャッシングはデフォルトでは無効ですが、次のプロパティを設定することで、キャッシュ単位で有効にすることができます:

quarkus.infinispan-client.cache.books.near-cache-mode=INVALIDATED (1)
quarkus.infinispan-client.cache.books.near-cache-max-entries=200 (2)
quarkus.infinispan-client.cache.books.near-cache-use-bloom-filter=true (3)
1 モードを INVALIDATED に設定して 'books' キャッシュのニアキャッシュを有効にします
2 'books' キャッシュのエビクションが発生するまでにニアキャッシュが保持できる最大エントリ数を設定します
3 'books' キャッシュのブルームフィルタを有効にします

境界付けられたニアキャッシング

キャッシュに格納できるエントリーの最大数を指定し、常に境界付けられたニアキャッシュを使用する必要があります。

ブルームフィルタ

無効化メッセージの総数を減らすことで書き込み操作のパフォーマンスを最適化する必要がある場合はブルームフィルタを有効にします。ブルームフィルタは Infinispan Server に常駐し、クライアントが要求したエントリを追跡します。 これらは、境界付けられていないニアキャッシュでは使用できません。ブルームフィルタを有効にする際には、エントリの最大数を定義する必要があります。

暗号化

この時点での暗号化には、作業を開始するための追加のステップが必要です。

最初のステップは、 hotrod-client.properties ファイルがトラストストアおよび/またはキーストアを指すように設定することです。これについては、 ここ でさらに詳しく説明します。

Infinispanクライアント拡張は、デフォルトでSSL/TLSを有効にします。これについては Using SSL With Native Executables に詳しく書かれています。

追加機能

Infinispanクライアントには、ここに記載されていない追加機能があります。これは、この機能がQuarkus環境でテストされていないことを意味し、それらは動作するかもしれませんし、動作しないかもしれません。これらの追加機能が必要な場合は、ぜひお知らせください。

Dev Services for Infinispan

開発モードまたはテストでinfinispan-clientエクステンションを使用すると、Quarkusは自動的にInfinispanサーバーを起動し、アプリケーションを設定します。

Infinispanの開発サービスの有効化/無効化

Infinispanの開発サービスは、以下の条件が満たされない限り自動的に有効になります:

  • quarkus.infinispan-client.devservices.enabledfalse に設定されている

  • quarkus.infinispan-client.hosts が設定されている

  • quarkus.infinispan-client.uri が設定されている

Infinispan 開発サービスはブローカーの起動に Docker を利用しています。 お使いの環境が Docker をサポートしていない場合、ブローカーを手動で起動するか、すでに起動しているブローカーに接続する必要があります。 ブローカーのアドレスは quarkus.infinispan-client.server-list を使用して設定できます。

共有サーバー

開発モードで複数のアプリケーションを実行している場合、QuarkusはInfinispanブローカーを共有します。 Infinispanの開発サービスは、 dev モードで実行されている複数のQuarkusアプリケーションが1つのブローカーを共有するための service discovery メカニズムを実装しています。

Infinispanの開発サービス は、コンテナを識別するために使用される quarkus-dev-service-infinispan ラベルでコンテナを起動します。

複数の(共有)Infinispanサーバーが必要な場合は、 quarkus.infinispan-client.devservices.service-name 属性を設定して、サーバー名を指定することが可能です。 同じ値を持つコンテナを探すか、見つからない場合は新しいコンテナを起動します。 デフォルトのサービス名は infinispan です。

共有は、開発モードではデフォルトで有効ですが、テストモードでは無効になります。 共有は quarkus.infinispan-client.devservices.shared=false で無効にすることができます。

ポートの設定

デフォルトでは、Infinispanの開発サービスはランダムなポートを選択し、アプリケーションを設定します。 ポートは quarkus.infinispan-client.devservices.port プロパティを設定することによって定義することができます。

テストヘルパー

ユニットテスト用に Infinispan Server を起動するために、Quarkus は Infinispan Server Test Container に依存する QuarkusTestResourceLifecycleManager を1つ提供します。

  • io.quarkus.test.infinispan.client.InfinispanTestResource は、ポート 11222 で、ユーザー 'admin' とパスワード 'password' で単一のインスタンスを起動します。

これらを使用するには、 io.quarkus:quarkus-test-infinispan-client の依存関係を pom.xml に追加する必要があります。

QuarkusTestResourceLifecycleManager の使用方法の詳細については、 Quarkus テストリソース を参照してください。

設定リファレンス

ビルド時に固定される設定プロパティ - 他のすべての設定プロパティは実行時にオーバーライド可能

Configuration property

タイプ

デフォルト

If DevServices has been explicitly enabled or disabled. DevServices is generally enabled by default, unless there is an existing configuration present. When DevServices is enabled Quarkus will attempt to automatically configure and start a database when running in Dev or Test mode and when Docker is running.

Environment variable: QUARKUS_INFINISPAN_CLIENT_DEVSERVICES_ENABLED

Show more

boolean

true

Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly.

Environment variable: QUARKUS_INFINISPAN_CLIENT_DEVSERVICES_PORT

Show more

int

Indicates if the Infinispan server managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. If a matching container is found, it is used, and so a second one is not started. Otherwise, Dev Services for Infinispan starts a new container. The discovery uses the quarkus-dev-service-infinispan label. The value is configured using the service-name property. Container sharing is only used in dev mode.

Environment variable: QUARKUS_INFINISPAN_CLIENT_DEVSERVICES_SHARED

Show more

boolean

true

The value of the quarkus-dev-service-infinispan label attached to the started container. This property is used when shared is set to true. In this case, before starting a container, Dev Services for Infinispan looks for a container with the quarkus-dev-service-infinispan label set to the configured value. If found, it will use this container instead of starting a new one. Otherwise, it starts a new container with the quarkus-dev-service-infinispan label set to the specified value. This property is used when you need multiple shared Infinispan servers.

Environment variable: QUARKUS_INFINISPAN_CLIENT_DEVSERVICES_SERVICE_NAME

Show more

string

infinispan

The image to use. Note that only official Infinispan images are supported.

Environment variable: QUARKUS_INFINISPAN_CLIENT_DEVSERVICES_IMAGE_NAME

Show more

string

List of the artifacts to automatically download and add to the Infinispan server libraries. For example a Maven coordinate (org.postgresql:postgresql:42.3.1) or a dependency location url. If an invalid value is passed, the Infinispan server will throw an error when trying to start.

Environment variable: QUARKUS_INFINISPAN_CLIENT_DEVSERVICES_ARTIFACTS

Show more

文字列のリスト

Whether a health check is published in case the smallrye-health extension is present.

Environment variable: QUARKUS_INFINISPAN_CLIENT_HEALTH_ENABLED

Show more

boolean

true

Sets the bounded entry count for near cache. If this value is 0 or less near cache is disabled.

Environment variable: QUARKUS_INFINISPAN_CLIENT_NEAR_CACHE_MAX_ENTRIES

Show more

int

0

Sets the URI of the running Infinispan server to connect to. hotrod://localhost:11222@admin:password If provided hosts, username and password will be ignored.

Environment variable: QUARKUS_INFINISPAN_CLIENT_URI

Show more

string

Sets the host name/port to connect to. Each one is separated by a semicolon (eg. host1:11222;host2:11222).

Environment variable: QUARKUS_INFINISPAN_CLIENT_HOSTS

Show more

string

Enables or disables Protobuf generated schemas upload to the server. Set it to 'false' when you need to handle the lifecycle of the Protobuf Schemas on Server side yourself. Default is 'true'.

Environment variable: QUARKUS_INFINISPAN_CLIENT_USE_SCHEMA_REGISTRATION

Show more

boolean

true

Sets client intelligence used by authentication Available values: * BASIC - Means that the client doesn’t handle server topology changes and therefore will only use the list of servers supplied at configuration time. * TOPOLOGY_AWARE - Use this provider if you don’t want the client to present any certificates to the remote TLS host. * HASH_DISTRIBUTION_AWARE - Like TOPOLOGY_AWARE but with the additional advantage that each request involving keys will be routed to the server who is the primary owner which improves performance greatly. This is the default.

Environment variable: QUARKUS_INFINISPAN_CLIENT_CLIENT_INTELLIGENCE

Show more

string

HASH_DISTRIBUTION_AWARE

Enables or disables authentication. Set it to false when connecting to an Infinispan Server without authentication. deployments. Default is 'true'.

Environment variable: QUARKUS_INFINISPAN_CLIENT_USE_AUTH

Show more

boolean

true

Sets username used by authentication.

Environment variable: QUARKUS_INFINISPAN_CLIENT_USERNAME

Show more

string

Sets password used by authentication.

Environment variable: QUARKUS_INFINISPAN_CLIENT_PASSWORD

Show more

string

Sets realm used by authentication

Environment variable: QUARKUS_INFINISPAN_CLIENT_AUTH_REALM

Show more

string

default

Sets server name used by authentication

Environment variable: QUARKUS_INFINISPAN_CLIENT_AUTH_SERVER_NAME

Show more

string

infinispan

Sets client subject, necessary for those SASL mechanisms which require it to access client credentials.

Environment variable: QUARKUS_INFINISPAN_CLIENT_AUTH_CLIENT_SUBJECT

Show more

string

Specifies a CallbackHandler to be used during the authentication handshake. The `Callback`s that need to be handled are specific to the chosen SASL mechanism.

Environment variable: QUARKUS_INFINISPAN_CLIENT_AUTH_CALLBACK_HANDLER

Show more

string

Sets SASL mechanism used by authentication. Available values: * DIGEST-MD5 - Uses the MD5 hashing algorithm in addition to nonces to encrypt credentials. This is the default. * EXTERNAL - Uses client certificates to provide valid identities to Infinispan Server and enable encryption. * PLAIN - Sends credentials in plain text (unencrypted) over the wire in a way that is similar to HTTP BASIC authentication. You should use PLAIN authentication only in combination with TLS encryption.

Environment variable: QUARKUS_INFINISPAN_CLIENT_SASL_MECHANISM

Show more

string

DIGEST-MD5

Specifies the filename of a truststore to use to create the SSLContext. You also need to specify a trustStorePassword. Setting this property implicitly enables SSL/TLS.

Environment variable: QUARKUS_INFINISPAN_CLIENT_TRUST_STORE

Show more

string

Specifies the password needed to open the truststore You also need to specify a trustStore. Setting this property implicitly enables SSL/TLS.

Environment variable: QUARKUS_INFINISPAN_CLIENT_TRUST_STORE_PASSWORD

Show more

string

Specifies the type of the truststore, such as JKS or JCEKS. Defaults to JKS if trustStore is enabled.

Environment variable: QUARKUS_INFINISPAN_CLIENT_TRUST_STORE_TYPE

Show more

string

Configures the secure socket protocol. Setting this property implicitly enables SSL/TLS.

Environment variable: QUARKUS_INFINISPAN_CLIENT_SSL_PROTOCOL

Show more

string

Sets the ssl provider. For example BCFIPS Setting this implicitly enables SSL/TLS.

Environment variable: QUARKUS_INFINISPAN_CLIENT_SSL_PROVIDER

Show more

string

Configures the ciphers. Setting this property implicitly enables SSL/TLS.

Environment variable: QUARKUS_INFINISPAN_CLIENT_SSL_CIPHERS

Show more

文字列のリスト

Cache configuration in inlined XML to create the cache on first access. Will be ignored if the configuration-uri is provided for the same cache name. An example of the user defined property: quarkus.infinispan-client.cache.bookscache.configuration=

Environment variable: QUARKUS_INFINISPAN_CLIENT_CACHE__CACHE__CONFIGURATION

Show more

string

Cache configuration file in XML whose path will be converted to URI to create the cache on first access. An example of the user defined property. cacheConfig.xml file is located in the 'resources' folder: quarkus.infinispan-client.cache.bookscache.configuration-uri=cacheConfig.xml

Environment variable: QUARKUS_INFINISPAN_CLIENT_CACHE__CACHE__CONFIGURATION_URI

Show more

string

The maximum number of entries to keep locally for the specified cache.

Environment variable: QUARKUS_INFINISPAN_CLIENT_CACHE__CACHE__NEAR_CACHE_MAX_ENTRIES

Show more

int

Sets near cache mode used by the Infinispan Client Available values: * DISABLED - Means that near caching is disabled. This is the default value. * INVALIDATED - Means is near caching is invalidated, so when entries are updated or removed server-side, invalidation messages will be sent to clients to remove them from the near cache.

Environment variable: QUARKUS_INFINISPAN_CLIENT_CACHE__CACHE__NEAR_CACHE_MODE

Show more

disabled, invalidated

Enables bloom filter for near caching. Bloom filters optimize performance for write operations by reducing the total number of invalidation messages.

Environment variable: QUARKUS_INFINISPAN_CLIENT_CACHE__CACHE__NEAR_CACHE_USE_BLOOM_FILTER

Show more

boolean