クイック・スタート

次のステップを実行して、REST APIを使用して環境を設定し、管理データにアクセスします:

ノート:

クイック・スタート・ステップは、スタンドアロンCoherenceの管理に固有です。WebLogic Serverドメインで管理対象Coherenceサーバーを使用している場合は、次のURLを使用して管理情報にアクセスします:

http://<admin-host>:<admin-port>/management/coherence/<version>/clusters
  • バージョン番号は、12.2.1.4.0などの5桁の完全な数字である必要があります。
  • バージョンは最新のものにすることもできます。

API参照のすべてのRESTリソースは、管理対象Coherenceサーバーで使用可能です。

前提条件

前提条件 詳細情報

Coherence

Coherenceをインストールし、クラスタを設定します。Oracle CoherenceのインストールOracle Coherence for Javaのインストールを参照してください。

cURL

このドキュメント内の例では、cURLコマンド行ツールを使用して、Oracle Coherence管理のREST APIにアクセスする方法を示しています。cURLは、http://curl.haxx.seからダウンロードできます。

ステップ1: REST Managementの有効化

REST管理は、Coherenceクラスタ上でプロキシとして稼働するHTTP管理サーバーを介して有効化されます。HTTP管理サーバーには、COHERENCE_HOME\lib\coherence-management.jarライブラリおよびサード・パーティの依存関係が必要です。このサーバーが起動するのは、management-config<http-managed-nodes>要素がallまたはinheritに設定されており、必要なライブラリがクラスパスにある場合です。ライブラリが見つからない場合、管理ライブラリが欠落しておりHTTPを介して管理できないことがCoherenceログ・メッセージに示されます。Coherence Distributionには、サード・パーティのライブラリは含まれません。

Mavenを使用して依存関係を管理することをお薦めします。「Mavenリポジトリ・マネージャの移入」の説明に従ってOracle Maven同期プラグインを使用して最新のOracle Coherenceアーティファクトがローカルのmavenリポジトリにインストールされていることを前提とします。サード・パーティ・ライブラリを含むクラスパスを生成するには、提供されている以下のpom.xmlを指定して、次のMavenコマンドを実行します。生成されたクラスパスを追加して、サーバー・スクリプトを起動します。

mvn dependency:build-classpath

ノート:

JDK 11で実行している場合は、-P jdk11をmvnコマンドラインに追加して、JDK 11の一部ではなくなった追加ライブラリを取得します。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <artifactId>management</artifactId>
  <groupId>management</groupId>
  <version>12.2.1-4-0</version>
  <name>Coherence Management Over REST dependencies</name>
  <packaging>pom</packaging>
  
  <dependencies>
    <dependency>
      <groupId>com.oracle.coherence</groupId>
      <artifactId>coherence-management</artifactId>
      <version>${project.version}</version>
    </dependency>
  </dependencies>
  
  <profiles>
    <profile>
      <id>jdk11</id>
      <properties>
        <com.sun.xml.bind.version>2.3.0</com.sun.xml.bind.version>
        <javax.activation.version>1.1.1</javax.activation.version>
      </properties>
      <dependencies>
	<dependency>
          <groupId>com.sun.xml.bind</groupId>
          <artifactId>jaxb-core</artifactId>
          <version>${com.sun.xml.bind.version}</version>
        </dependency>
        <dependency>
          <groupId>com.sun.xml.bind</groupId>
          <artifactId>jaxb-impl</artifactId>   
          <version>${com.sun.xml.bind.version}</version>
        </dependency>
        <dependency>
          <groupId>javax.activation</groupId>
          <artifactId>activation</artifactId>
          <version>${javax.activation.version}</version>
        </dependency>
        <dependency>
          <groupId>javax.xml.bind</groupId>
          <artifactId>jaxb-api</artifactId>
          <version>${com.sun.xml.bind.version}</version>
        </dependency>
      </dependencies>
    </profile>
  </profiles>

</project>

必要なすべての依存性が自動的にダウンロードされます。ライブラリの完全なリストを表示するには、次のMavenコマンドを実行します。

mvn dependency:list

ノート:

RESTポートを介した管理を変更するには、Oracle Coherenceの管理HTTP管理サーバー・アドレスの変更を参照してください。

ステップ2: 管理URLの取得

このステップでは、management-config要素の子要素<http-named-nodes>inheritに構成することにより、クラスタの動的HTTP管理サーバーが有効な場合に管理URLを取得する方法について説明します。

Coherenceログは、HTTP管理サーバーのポートを示します:

(thread=Proxy:ManagementHttpProxy:HttpAcceptor, member=1): HttpAcceptor now listening for connections on 0:0:0:0:0:0:0:0:30000

com.tangosol.discovery.NSLookupクラスを使用して、任意のクラスタ・メンバーに対してNameServiceサービスを問い合せることもできます。たとえば:

java -cp %COHERENCE_HOME%\lib\coherence.jar com.tangosol.discovery.NSLookup -name management/HTTPManagementURL

Cluster MyCluster:      [http://127.0.0.1:30000/management/coherence/cluster]

ステップ3: アクセス管理情報

次の例では、cURLを使用して、REST APIを使用したデモを示しています。この例では、クラスタ上のキャッシュのリストを取得し、hello-exampleという名前のキャッシュの詳細な管理情報を取得します。

リクエスト:

curl -i -X GET http://127.0.0.1:30000/management/coherence/cluster/caches

レスポンス:

HTTP/1.1 200 OK
Content-Type: application/json
content-length: 697
connection: keep-alive

{
	"links": [{
		"rel": "parent",
		"href": "http://127.0.0.1:30000/management/coherence/cluster"
	}, {
		"rel": "self",
		"href": "http://127.0.0.1:30000/management/coherence/cluster/caches"
	}, {
		"rel": "canonical",
		"href": "http://127.0.0.1:30000/management/coherence/cluster/caches"
	}],
	"items": [{
		"links": [{
			"rel": "parent",
			"href": "http://127.0.0.1:30000/management/coherence/cluster/caches"
		}, {
			"rel": "self",
			"href": "http://127.0.0.1:30000/management/coherence/cluster/caches/hello-example"
		}, {
			"rel": "canonical",
			"href": "http://127.0.0.1:30000/management/coherence/cluster/caches/hello-example"
		}, {
			"rel": "members",
			"href": "http://127.0.0.1:30000/management/coherence/cluster/caches/hello-example/members"
		}],
		"name": "hello-example"
	}]
}

リクエスト:

curl -i -X GET http://127.0.0.1:30000/management/coherence/cluster/caches/hello-example

レスポンス:

HTTP/1.1 200 OK
Content-Type: application/json
content-length: 1981
connection: keep-alive

{
	"links": [{
		"rel": "parent",
		"href": "http://127.0.0.1:30000/management/coherence/cluster/caches"
	}, {
		"rel": "self",
		"href": "http://127.0.0.1:30000/management/coherence/cluster/caches/hello-example"
	}, {
		"rel": "canonical",
		"href": "http://127.0.0.1:30000/management/coherence/cluster/caches/hello-example"
	}, {
		"rel": "members",
		"href": "http://127.0.0.1:30000/management/coherence/cluster/caches/hello-example/members"
	}],
	"name": "hello-example",
	"totalGetsMillis": 0,
	"description": ["Implementation: com.tangosol.net.cache.LocalCache"],
	"lowUnits": 800,
	"size": 19,
	"totalPuts": 20,
	"totalPutsMillis": 0,
	"refreshTime": ["2018-12-14T17:43:40.642+0000"],
	"requeueThreshold": [0],
	"averageMissMillis": {
		"average": 0.0,
		"count": 1,
		"max": 0.0,
		"min": 0.0,
		"sum": 0.0
	},
	"highUnits": 1000,
	"hitProbability": {
		"average": 0.0,
		"count": 1,
		"max": 0.0,
		"min": 0.0,
		"sum": 0.0
	},
	"totalGets": 0,
	"unitFactor": [1],
	"averageHitMillis": {
		"average": 0.0,
		"count": 1,
		"max": 0.0,
		"min": 0.0,
		"sum": 0.0
	},
	"refreshFactor": [0.0],
	"memoryUnits": {
		"false": 1
	},
	"cachePrunesMillis": 0,
	"batchFactor": [0.0],
	"cacheMissesMillis": 0,
	"averageGetMillis": {
		"average": 0.0,
		"count": 1,
		"max": 0.0,
		"min": 0.0,
		"sum": 0.0
	},
	"averagePutMillis": {
		"average": 0.0,
		"count": 1,
		"max": 0.0,
		"min": 0.0,
		"sum": 0.0
	},
	"persistenceType": ["NONE"],
	"cacheStoreType": ["NONE"],
	"units": 19,
	"cacheHits": 0,
	"cacheMisses": 0,
	"expiryDelay": [0],
	"cacheHitsMillis": 0,
	"cachePrunes": 0,
	"evictionCount": 0,
	"insertCount": 19,
	"listenerKeyCount": 0,
	"nonOptimizedQueryTotalMillis": {
		"count": 1,
		"average": 0.0,
		"min": 0,
		"max": 0,
		"sum": 0
	},
	"listenerRegistrations": 0,
	"listenerFilterCount": [0],
	"nonOptimizedQueryCount": 0,
	"locksGranted": 0,
	"indexTotalUnits": 0,
	"optimizedQueryAverageMillis": {
		"count": 1,
		"average": 0.0,
		"min": 0,
		"max": 0,
		"sum": 0
	},
	"optimizedQueryTotalMillis": {
		"count": 1,
		"average": 0.0,
		"min": 0,
		"max": 0,
		"sum": 0
	},
	"removeCount": 0,
	"locksPending": 0,
	"queryContentionCount": 0,
	"eventsDispatched": 0,
	"optimizedQueryCount": 0,
	"maxQueryDurationMillis": 0,
	"maxQueryThresholdMillis": [30],
	"nonOptimizedQueryAverageMillis": {
		"count": 1,
		"average": 0.0,
		"min": 0,
		"max": 0,
		"sum": 0
	}
}