1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//
#ifndef ICEGRID_SESSIONI_H
#define ICEGRID_SESSIONI_H
#include <IceUtil/Timer.h>
#include <IceGrid/ReapThread.h>
#include <IceGrid/Session.h>
#include <IceGrid/SessionServantManager.h>
#include <set>
namespace IceGrid
{
class Allocatable;
class AllocationRequest;
class Database;
class SessionI;
class TraceLevels;
class BaseSessionI : public virtual Ice::Object, public std::enable_shared_from_this<BaseSessionI>
{
public:
virtual ~BaseSessionI() = default;
virtual void keepAlive(const Ice::Current&);
std::chrono::steady_clock::time_point timestamp() const;
void shutdown();
std::shared_ptr<Glacier2::IdentitySetPrx> getGlacier2IdentitySet();
std::shared_ptr<Glacier2::StringSetPrx> getGlacier2AdapterIdSet();
const std::string& getId() const { return _id; }
virtual void destroyImpl(bool);
protected:
BaseSessionI(const std::string&, const std::string&, const std::shared_ptr<Database>&);
const std::string _id;
const std::string _prefix;
const std::shared_ptr<TraceLevels> _traceLevels;
const std::shared_ptr<Database> _database;
std::shared_ptr<SessionServantManager> _servantManager;
bool _destroyed;
std::chrono::steady_clock::time_point _timestamp;
mutable std::mutex _mutex;
};
struct SessionDestroyedException
{
};
class SessionI final : public BaseSessionI, public Session
{
public:
SessionI(const std::string&, const std::shared_ptr<Database>&, const IceUtil::TimerPtr&);
std::shared_ptr<Ice::ObjectPrx> _register(const std::shared_ptr<SessionServantManager>&,
const std::shared_ptr<Ice::Connection>&);
void keepAlive(const Ice::Current& current) override { BaseSessionI::keepAlive(current); }
void allocateObjectByIdAsync(Ice::Identity id,
std::function<void(const std::shared_ptr<Ice::ObjectPrx>& returnValue)> response,
std::function<void(std::exception_ptr)> exception, const Ice::Current& current)
override;
void allocateObjectByTypeAsync(std::string,
std::function<void(const std::shared_ptr<Ice::ObjectPrx>& returnValue)> response,
std::function<void(std::exception_ptr)> exception, const Ice::Current& current)
override;
void releaseObject(Ice::Identity, const Ice::Current&) override;
void setAllocationTimeout(int, const Ice::Current&) override;
void destroy(const Ice::Current&) override;
int getAllocationTimeout() const;
const IceUtil::TimerPtr& getTimer() const { return _timer; }
bool addAllocationRequest(const std::shared_ptr<AllocationRequest>&);
void removeAllocationRequest(const std::shared_ptr<AllocationRequest>&);
void addAllocation(const std::shared_ptr<Allocatable>&);
void removeAllocation(const std::shared_ptr<Allocatable>&);
protected:
void destroyImpl(bool) override;
const IceUtil::TimerPtr _timer;
int _allocationTimeout;
std::set<std::shared_ptr<AllocationRequest>> _requests;
std::set<std::shared_ptr<Allocatable>> _allocations;
};
class ClientSessionFactory final
{
public:
ClientSessionFactory(const std::shared_ptr<SessionServantManager>&, const std::shared_ptr<Database>&,
const IceUtil::TimerPtr&,
const std::shared_ptr<ReapThread>&);
std::shared_ptr<Glacier2::SessionPrx> createGlacier2Session(const std::string&,
const std::shared_ptr<Glacier2::SessionControlPrx>&);
std::shared_ptr<SessionI> createSessionServant(const std::string&,
const std::shared_ptr<Glacier2::SessionControlPrx>&);
const std::shared_ptr<TraceLevels>& getTraceLevels() const;
private:
const std::shared_ptr<SessionServantManager> _servantManager;
const std::shared_ptr<Database> _database;
const IceUtil::TimerPtr _timer;
const std::shared_ptr<ReapThread> _reaper;
const bool _filters;
};
class ClientSessionManagerI final : public Glacier2::SessionManager
{
public:
ClientSessionManagerI(const std::shared_ptr<ClientSessionFactory>&);
std::shared_ptr<Glacier2::SessionPrx> create(std::string, std::shared_ptr<Glacier2::SessionControlPrx>,
const Ice::Current&) override;
private:
const std::shared_ptr<ClientSessionFactory> _factory;
};
class ClientSSLSessionManagerI final : public Glacier2::SSLSessionManager
{
public:
ClientSSLSessionManagerI(const std::shared_ptr<ClientSessionFactory>&);
std::shared_ptr<Glacier2::SessionPrx> create(Glacier2::SSLInfo, std::shared_ptr<Glacier2::SessionControlPrx>,
const Ice::Current&) override;
private:
const std::shared_ptr<ClientSessionFactory> _factory;
};
};
#endif
|