コンポーネント・インスタンスのリスト表示

ComponentInstanceManager.listComponentInstances()メソッドをコールして、Endeca IAS Serviceのすべてのコンポーネント・インスタンスをリスト表示します。このリリースでは、コンポーネントは、Endeca IAS Serviceで実行中のレコード・ストア・インスタンスです。

このメソッドの構文は、次のとおりです。
ComponentInstanceManager.listComponentInstances()
メソッドは、ComponentInstanceDescriptorオブジェクトのリストを返します。各ComponentInstanceDescriptorオブジェクトは、単一のコンポーネント(つまり、レコード・ストア・インスタンス)を表し、次で構成されます。
  • TypeIdオブジェクト。これは、コンポーネント・タイプです。たとえば、このリリースでは、これは常にRecordStoreです。
  • InstanceIdオブジェクト。これは、ユーザー指定のインスタンス名です。
  • InstanceStatusオブジェクト。これは、レコード・ストア・インスタンスのステータスです。この値には、RUNNINGFAILEDまたはSTOPPEDの定数のいずれかを指定できます。

コンポーネント・インスタンスをリスト表示するには:

  1. ServiceAddressオブジェクトを作成し、Component Instance Managerを実行しているサーバーのホストおよびポートを指定し、WebLogicにIASをインストールしている場合は、さらにcontextPathを指定します。JettyにIASをインストールしている場合は、contextPathを空の文字列に設定します。
  2. ComponentInstanceManagerLocatorcreate()メソッドをコールし、ServiceAddressオブジェクトに渡します。たとえば、次のようになります。
    ServiceAddress address = new ServiceAddress("localhost", 8401, contextPath); 
    ComponentInstanceManagerLocator locator = ComponentInstanceManagerLocator.create(address);
  3. ComponentInstanceManagerオブジェクトを作成し、getService()をコールして、サーバーおよびComponent Instance Managerサービスへの接続を確立します。たとえば、次のようになります。
    ComponentInstanceManager cim = locator.getService();
  4. listComponentInstances()をコールし、次にforループを作成して、すべてのコンポーネント・インスタンスをループ処理します。ループ内で、TypeIdInstanceIdおよびInstanceStatusを取得して、それらをシステムの外部(またはその他の場所)に出力します。たとえば、次のようになります。
    for (ComponentInstanceDescriptor desc : cim.listComponentInstances()) {
    	System.out.println(desc.getInstanceId() + " of type " + desc.getTypeId() + " has status " + desc.getInstanceStatus());
    }