Hitachi

VisiBroker Version 5 Borland(R) Enterprise Server VisiBroker(R) デベロッパーズガイド


14.11.3 クラスタの生成

クラスタを生成するには,Cluster Managerインタフェースを使用します。ネーミングサーバの起動時に,Cluster Managerオブジェクトが一つだけ自動的に生成されます。Cluster Managerはネーミングサーバごとに一つだけあります。Cluster Managerの役割は,ネーミングサーバ内のクラスタの生成,検索,および状態の把握です。

  1. クラスタオブジェクトの生成に使用したいネーミングサーバにバインドします。

  2. ファクトリリファレンスのget_cluster_managerメソッド呼び出しによって,Cluster Managerへのリファレンスを取得します。

  3. 指定されたクラスタの方法でクラスタを生成します。

  4. クラスタを使用して,オブジェクトをNameにバインドします。

  5. Clusterオブジェクト自身をNameにバインドします。

  6. 指定されたクラスタの方法のClusterリファレンスによって解決します。

コードサンプル14-7 Clusterオブジェクトの生成と使用(C++)
. . .
ExtendedNamingContextFactory_var myFactory = 
      ExtendedNamingContextFactory::_bind(orb, "NamingService");
ClusterManager_var clusterMgr = 
      myFactory->get_cluster_manager();
Cluster_var clusterObj = 
      clusterMgr->create_cluster("RoundRobin");
clusterObj->bind(new NameComponent(
      "member1", "aCluster"), obj1);
clusterObj->bind(new NameComponent(
      "member2", "aCluster"), obj2);
clusterObj->bind(new NameComponent(
      "member3", "aCluster"), obj3);
NameComponent_var myClusterName = 
      new NameComponent("ClusterName", "");
root->bind(myClusterName, clusterObj);
root->resolve(myClusterName); 
      // a member of the Cluster is returned
root->resolve(myClusterName); 
      // the next member of the Cluster is returned
root->resolve(myClusterName); 
      // the last member of the Cluster is returned
. . .
コードサンプル14-8 Clusterオブジェクトの生成と使用(Java)
. . .
ExtendedNamingContextFactory myFactory =
    ExtendedNamingContextFactoryHelper.bind(orb,
                                           "NamingService");
ClusterManager clusterMgr = myFactory.get_cluster_manager();
Cluster clusterObj = clusterMgr.create_cluster("RoundRobin");
clusterObj.bind(new NameComponent("member1", "aCluster"),
                obj1);
clusterObj.bind(new NameComponent("member2", "aCluster"),
                obj2);
clusterObj.bind(new NameComponent("member3", "aCluster"),
                obj3);
NameComponent myClusterName =
                        new NameComponent("ClusterName", "");
root.bind(myClusterName, clusterObj);
root.resolve(myClusterName) //
                        a member of the Cluster is returned.
root.resolve(myClusterName) //
                 the next member of the Cluster is returned.
root.resolve(myClusterName) //
                 the last member of the Cluster is returned.
. . .
〈この項の構成〉

(1) 明示的なクラスタと暗黙的なクラスタ

クラスタ化機能はネーミングサービスに対して自動的にオンになります。注意点は,この機能がオンになると,オブジェクトをバインドするためにクラスタが透過的に生成されるということです。使用の方法はラウンドロビンに固定されます。この影響は,ネーミングサーバ内の同じ名前に幾つかのオブジェクトをバインドできるということです。反対に,この名前を解決すると,これらのオブジェクトの一つが返され,unbindオペレーションはその名前に対応するクラスタをデストラクトします。これは,ネーミングサービスがCORBAの仕様に準拠しなくなったという意味です。インターオペラブルネーミングサービスの仕様では,複数のオブジェクトを同じ名前でバインドする機能を明示的に禁止します。準拠しているネーミングサービスでは,クライアントが同じ名前を使用して異なるオブジェクトにバインドしようとすると,AlreadyBound例外が発生します。ユーザは最初から,個々のサーバにこの機能を使用するかどうかを決定する必要があり,その決定を守るべきです。

暗黙的なクラスタモードから明示的なクラスタモードへの切り替えはできません。バッキングストアを破壊するおそれがあるためです。

ネーミングサーバを暗黙的なクラスタ化機能と一緒に使用した場合,クラスタ化機能をオンにした状態でネーミングサーバを引き続き活性化してください。機能をオンにするには,構成ファイルに次のプロパティ値を定義してください。

vbroker.naming.propBindOn=1

明示的なクラスタ化および暗黙的なクラスタ化の両方のサンプルについては,次のインストールディレクトリ下の次のディレクトリのコードを参照してください。

examples/vbe/ins/implicit_clustering
examples/vbe/ins/explicit_clustering