~ubuntu-branches/ubuntu/quantal/zeroc-ice/quantal

« back to all changes in this revision

Viewing changes to src/IceGrid/AdapterCache.h

  • Committer: Bazaar Package Importer
  • Author(s): Francisco Moya
  • Date: 2006-08-06 19:00:57 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060806190057-3q4p9ws4ucyamn10
Tags: 3.1.0-2
* Patches #5 to #6 from ZeroC forums.
* Patch by Michael Pugach for DescriptorHelper.cpp.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// **********************************************************************
2
2
//
3
 
// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
 
3
// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved.
4
4
//
5
5
// This copy of Ice is licensed to you under the terms described in the
6
6
// ICE_LICENSE file included in this distribution.
28
28
class AdapterEntry;
29
29
typedef IceUtil::Handle<AdapterEntry> AdapterEntryPtr;
30
30
 
31
 
class AdapterEntry : public IceUtil::Shared, public IceUtil::Mutex
 
31
class AdapterEntry : virtual public IceUtil::Shared, public IceUtil::Mutex
32
32
{
33
33
public:
34
34
    
35
 
    AdapterEntry(Cache<std::string, AdapterEntry>&, const std::string&);
36
 
 
37
 
    virtual std::vector<std::pair<std::string, AdapterPrx> > getProxies(bool, int&) { 
38
 
        return std::vector<std::pair<std::string, AdapterPrx> >(); }
39
 
    virtual float getLeastLoadedNodeLoad(LoadSample) const { return 0.0f; }
40
 
    virtual std::string getApplication() const { return ""; }
 
35
    AdapterEntry(AdapterCache&, const std::string&);
 
36
 
 
37
    virtual std::vector<std::pair<std::string, AdapterPrx> > getProxies(int&, bool&) = 0;
 
38
    virtual float getLeastLoadedNodeLoad(LoadSample) const = 0;
 
39
    virtual std::string getApplication() const = 0;
 
40
    virtual AdapterInfoSeq getAdapterInfo() const = 0;
 
41
 
41
42
    virtual bool canRemove();
42
43
    
43
44
protected:
44
 
    
 
45
 
45
46
    AdapterCache& _cache;
46
47
    const std::string _id;
47
48
};
51
52
{
52
53
public:
53
54
 
54
 
    ServerAdapterEntry(Cache<std::string, AdapterEntry>&, const std::string&);
 
55
    ServerAdapterEntry(AdapterCache&, const std::string&, const std::string&, const ServerEntryPtr&);
55
56
 
56
 
    virtual std::vector<std::pair<std::string, AdapterPrx> > getProxies(bool, int&);
 
57
    virtual std::vector<std::pair<std::string, AdapterPrx> > getProxies(int&, bool&);
57
58
    virtual float getLeastLoadedNodeLoad(LoadSample) const;
58
59
    virtual std::string getApplication() const;
59
 
 
60
 
    void set(const ServerEntryPtr&, const std::string&);
61
 
    void destroy();
62
 
 
63
 
    AdapterPrx getProxy(const std::string& = std::string()) const;
 
60
    virtual AdapterInfoSeq getAdapterInfo() const;
 
61
    virtual const std::string& getReplicaGroupId() const { return _replicaGroupId; }
 
62
 
 
63
    AdapterPrx getProxy(const std::string&, bool) const;
64
64
 
65
65
private:
66
66
    
67
67
    ServerEntryPtr getServer() const;
68
68
 
69
 
    ServerEntryPtr _server;
70
 
    std::string _replicaGroupId;
 
69
    const std::string _replicaGroupId;
 
70
    const ServerEntryPtr _server;
71
71
};
72
72
typedef IceUtil::Handle<ServerAdapterEntry> ServerAdapterEntryPtr;
73
73
 
75
75
{
76
76
public:
77
77
 
78
 
    ReplicaGroupEntry(Cache<std::string, AdapterEntry>&, const std::string&);
 
78
    ReplicaGroupEntry(AdapterCache&, const std::string&, const std::string&, const LoadBalancingPolicyPtr&);
79
79
 
80
 
    virtual std::vector<std::pair<std::string, AdapterPrx> > getProxies(bool, int&);
 
80
    virtual std::vector<std::pair<std::string, AdapterPrx> > getProxies(int&, bool&);
81
81
    virtual float getLeastLoadedNodeLoad(LoadSample) const;
82
82
    virtual std::string getApplication() const;
 
83
    virtual AdapterInfoSeq getAdapterInfo() const;
83
84
 
84
 
    void set(const std::string&, const LoadBalancingPolicyPtr&);
85
85
    void addReplica(const std::string&, const ServerAdapterEntryPtr&);
86
86
    void removeReplica(const std::string&);
87
87
 
 
88
    void update(const LoadBalancingPolicyPtr&);
 
89
 
 
90
    typedef std::vector<std::pair<std::string, ServerAdapterEntryPtr> > ReplicaSeq;
 
91
 
88
92
private:
89
93
 
 
94
    const std::string _application;
 
95
 
90
96
    LoadBalancingPolicyPtr _loadBalancing;
91
97
    int _loadBalancingNReplicas;
92
98
    LoadSample _loadSample;
93
 
    std::string _application;
94
 
    typedef std::vector<std::pair<std::string, ServerAdapterEntryPtr> > ReplicaSeq;
95
99
    ReplicaSeq _replicas;
96
100
    int _lastReplica;
97
101
};
101
105
{
102
106
public:
103
107
 
 
108
    ServerAdapterEntryPtr addServerAdapter(const std::string&, const std::string&, const ServerEntryPtr&);
 
109
    ReplicaGroupEntryPtr addReplicaGroup(const std::string&, const std::string&, const LoadBalancingPolicyPtr&);
 
110
 
104
111
    AdapterEntryPtr get(const std::string&) const;
105
 
    ServerAdapterEntryPtr getServerAdapter(const std::string&, bool = false) const;
106
 
    ReplicaGroupEntryPtr getReplicaGroup(const std::string&, bool = false) const;
 
112
    ServerAdapterEntryPtr getServerAdapter(const std::string&) const;
 
113
    ReplicaGroupEntryPtr getReplicaGroup(const std::string&) const;
107
114
    
 
115
    void removeServerAdapter(const std::string&);
 
116
    void removeReplicaGroup(const std::string&);
 
117
 
108
118
protected:
109
119
    
110
120
    virtual AdapterEntryPtr addImpl(const std::string&, const AdapterEntryPtr&);