クライアントからの Gemfire/Geode クラスター サイズ (DS 内のメンバー数) を知りたいです。これを知る最も簡単な方法は何ですか。関数サービスを使用してこれを取得できますが、より簡単な解決策を探しています。
5 に答える
0
Urizen、Rahul が言ったように、クライアントは別の分散システム (複数のサーバー、ロケーター、ピア メンバーを持つ) に接続された "孤独な分散システム" であり、クライアント DS で "cache.getDistributedSystem.getAllOhterMembers" を実行すると、メンバー情報が得られます。サーバー側の分散システムではなく、クライアントのみの。
Rahul のコード スニペットは、サーバー メンバーに関する情報のみを提供し、DS で利用可能なピア メンバーに関する情報は提供しません。
IMO では、Rahul のコードを少し変更して、ピア メンバーやロケーターも考慮する必要があります。
public class CountMemberFunction extends FunctionAdapter {
private static final long serialVersionUID = 1L;
@Override
public void execute(FunctionContext fc) {
Cache c = CacheFactory.getAnyInstance();
//Get other members of the system
Set<DistributedMember> dsMembers=
c.getDistributedSystem().getAllOtherMembers();
// add this member
dsMembers.add(c.getDistributedSystem().getDistributedMember)
fc.getResultSender().lastResult(dsMembers);
}
@Override
public String getId() {
return getClass().getName();
}
}
そして、onServers の代わりに onServer を使用します
Execution execution = FunctionService.onServer(gemCache);
ResultCollector rc = execution.execute(new CountMemberFunction());
List nodes = (List)rc.getResult();
println("Server nodes are " + nodes);
于 2015-06-18T06:52:58.463 に答える