10.5. 핫 로드 클라이언트


Hot Rod는 Data Grid가 원격 클라이언트와 함께 고성능 데이터 전송 기능을 제공하는 바이너리 TCP 프로토콜입니다.

클라이언트 인텔리전스

클라이언트 인텔리전스는 클라이언트가 Data Grid 노드에 요청을 찾고 보낼 수 있도록 Hot Rod 프로토콜이 제공하는 메커니즘을 나타냅니다.

OpenShift에서 실행되는 핫 Rod 클라이언트는 Data Grid 노드의 내부 IP 주소에 액세스할 수 있으므로 모든 클라이언트 인텔리전스를 사용할 수 있습니다. 기본 인텔리전스( HASH_DISTRIBUTION_AWARE )는 클라이언트가 기본 소유자로 요청을 라우팅하여 성능을 향상시킬 수 있기 때문에 권장됩니다.

OpenShift 외부에서 실행되는 핫 Rod 클라이언트는 BASIC 인텔리전스를 사용해야 합니다.

10.5.1. 핫 로드 설정 API

ConfigurationBuilder 인터페이스를 사용하여 Hot Rod 클라이언트 연결을 프로그래밍 방식으로 구성할 수 있습니다.

참고

$SERVICE_HOSTNAME:$PORT 는 Data Grid 클러스터에 액세스할 수 있는 호스트 이름과 포트를 나타냅니다. 이러한 변수를 환경의 실제 호스트 이름 및 포트로 교체해야 합니다.

On OpenShift

OpenShift에서 실행되는 핫 Rod 클라이언트는 다음 구성을 사용할 수 있습니다.

import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.infinispan.client.hotrod.configuration.SaslQop;
import org.infinispan.client.hotrod.impl.ConfigurationProperties;
...

ConfigurationBuilder builder = new ConfigurationBuilder();
      builder.addServer()
               .host("$SERVICE_HOSTNAME")
               .port(ConfigurationProperties.DEFAULT_HOTROD_PORT)
             .security().authentication()
               .username("username")
               .password("password")
               .realm("default")
               .saslQop(SaslQop.AUTH)
               .saslMechanism("SCRAM-SHA-512")
             .ssl()
               .sniHostName("$SERVICE_HOSTNAME")
               .trustStorePath("/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt");
Copy to Clipboard Toggle word wrap
Outside OpenShift

OpenShift 외부에서 실행되는 핫 Rod 클라이언트는 다음 구성을 사용할 수 있습니다.

import org.infinispan.client.hotrod.configuration.ClientIntelligence;
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.infinispan.client.hotrod.configuration.SaslQop;
...

ConfigurationBuilder builder = new ConfigurationBuilder();
      builder.addServer()
               .host("$SERVICE_HOSTNAME")
               .port("$PORT")
             .security().authentication()
               .username("username")
               .password("password")
               .realm("default")
               .saslQop(SaslQop.AUTH)
               .saslMechanism("SCRAM-SHA-512")
             .ssl()
               .sniHostName("$SERVICE_HOSTNAME")
               .trustStorePath("/path/to/tls.crt");
      builder.clientIntelligence(ClientIntelligence.BASIC);
Copy to Clipboard Toggle word wrap

10.5.2. 핫 Rod 클라이언트 속성

애플리케이션 classpath에서 hotrod-client.properties 파일을 사용하여 Hot Rod 클라이언트 연결을 구성할 수 있습니다.

참고

$SERVICE_HOSTNAME:$PORT 는 Data Grid 클러스터에 액세스할 수 있는 호스트 이름과 포트를 나타냅니다. 이러한 변수를 환경의 실제 호스트 이름 및 포트로 교체해야 합니다.

On OpenShift

OpenShift에서 실행되는 핫 Rod 클라이언트는 다음 속성을 사용할 수 있습니다.

# Connection
infinispan.client.hotrod.server_list=$SERVICE_HOSTNAME:$PORT

# Authentication
infinispan.client.hotrod.use_auth=true
infinispan.client.hotrod.auth_username=developer
infinispan.client.hotrod.auth_password=$PASSWORD
infinispan.client.hotrod.auth_server_name=$CLUSTER_NAME
infinispan.client.hotrod.sasl_properties.javax.security.sasl.qop=auth
infinispan.client.hotrod.sasl_mechanism=SCRAM-SHA-512

# Encryption
infinispan.client.hotrod.sni_host_name=$SERVICE_HOSTNAME
# Path to the TLS certificate.
# Clients automatically generate trust stores from certificates.
infinispan.client.hotrod.trust_store_path=/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt
Copy to Clipboard Toggle word wrap
Outside OpenShift

OpenShift 외부에서 실행되는 핫 Rod 클라이언트는 다음 속성을 사용할 수 있습니다.

# Connection
infinispan.client.hotrod.server_list=$SERVICE_HOSTNAME:$PORT

# Client intelligence
infinispan.client.hotrod.client_intelligence=BASIC

# Authentication
infinispan.client.hotrod.use_auth=true
infinispan.client.hotrod.auth_username=developer
infinispan.client.hotrod.auth_password=$PASSWORD
infinispan.client.hotrod.auth_server_name=$CLUSTER_NAME
infinispan.client.hotrod.sasl_properties.javax.security.sasl.qop=auth
infinispan.client.hotrod.sasl_mechanism=SCRAM-SHA-512

# Encryption
infinispan.client.hotrod.sni_host_name=$SERVICE_HOSTNAME
# Path to the TLS certificate.
# Clients automatically generate trust stores from certificates.
infinispan.client.hotrod.trust_store_path=tls.crt
Copy to Clipboard Toggle word wrap

10.5.3. Hot Rod Client를 사용하여 캐시 생성

Hot Rod 클라이언트를 사용하여 OpenShift에서 실행되는 Data Grid 클러스터에서 원격으로 캐시를 생성할 수 있습니다. 그러나 Data Grid는 Hot Rod 클라이언트 대신 Data Grid Console, CLI 또는 Cache CR을 사용하여 캐시를 생성하는 것이 좋습니다.

프로그래밍 방식으로 캐시 생성

다음 예제에서는 ConfigurationBuilder 에 캐시 구성을 추가한 다음 RemoteCacheManager 를 사용하여 생성하는 방법을 보여줍니다.

import org.infinispan.client.hotrod.DefaultTemplate;
import org.infinispan.client.hotrod.RemoteCache;
import org.infinispan.client.hotrod.RemoteCacheManager;
...

      builder.remoteCache("my-cache")
             .templateName(DefaultTemplate.DIST_SYNC);
      builder.remoteCache("another-cache")
             .configuration("<infinispan><cache-container><distributed-cache name=\"another-cache\"><encoding media-type=\"application/x-protostream\"/></distributed-cache></cache-container></infinispan>");
      try (RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build())) {
      // Get a remote cache that does not exist.
      // Rather than return null, create the cache from a template.
      RemoteCache<String, String> cache = cacheManager.getCache("my-cache");
      // Store a value.
      cache.put("hello", "world");
      // Retrieve the value and print it.
      System.out.printf("key = %s\n", cache.get("hello"));
Copy to Clipboard Toggle word wrap

이 예제에서는 XMLStringConfiguration() 메서드를 사용하여 CacheWithXMLConfiguration이라는 캐시를 만들어 캐시 구성을 XML로 전달하는 방법을 보여줍니다.

import org.infinispan.client.hotrod.RemoteCacheManager;
import org.infinispan.commons.configuration.XMLStringConfiguration;
...

private void createCacheWithXMLConfiguration() {
    String cacheName = "CacheWithXMLConfiguration";
    String xml = String.format("<infinispan>" +
                                  "<cache-container>" +
                                  "<distributed-cache name=\"%s\" mode=\"SYNC\">" +
                                    "<encoding media-type=\"application/x-protostream\"/>" +
                                    "<locking isolation=\"READ_COMMITTED\"/>" +
                                    "<transaction mode=\"NON_XA\"/>" +
                                    "<expiration lifespan=\"60000\" interval=\"20000\"/>" +
                                  "</distributed-cache>" +
                                  "</cache-container>" +
                                "</infinispan>"
                                , cacheName);
    manager.administration().getOrCreateCache(cacheName, new XMLStringConfiguration(xml));
    System.out.println("Cache with configuration exists or is created.");
}
Copy to Clipboard Toggle word wrap
핫 Rod 클라이언트 속성 사용

cacheManager.getCache() 가 존재하지 않는 캐시를 호출하면 Data Grid는 null을 반환하지 않고 핫 Rod 클라이언트 속성에서 생성합니다.

다음 예와 같이 Hot Rod 클라이언트 속성에 캐시 구성을 추가합니다.

# Add cache configuration
infinispan.client.hotrod.cache.my-cache.template_name=org.infinispan.DIST_SYNC
infinispan.client.hotrod.cache.another-cache.configuration=<infinispan><cache-container><distributed-cache name=\"another-cache\"/></cache-container></infinispan>
infinispan.client.hotrod.cache.my-other-cache.configuration_uri=file:/path/to/configuration.xml
Copy to Clipboard Toggle word wrap
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat
맨 위로 이동