-
Notifications
You must be signed in to change notification settings - Fork 596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix proxy usage and creation in IceGrid implementation #1933
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
cpp/src/IceBox/ServiceManagerI.cpp
Outdated
// Null observers are ignored | ||
if (observer) | ||
{ | ||
addObserver(*observer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we move it out of the optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we should.
cpp/src/IceGrid/AdminSessionI.cpp
Outdated
name == _replicaName ? _database->getReplicaCache().getInternalRegistry() | ||
: _database->getReplicaCache().getInternalRegistry(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the false case be _database->getReplica(std::move(name))->getProxy();
// the server is released during the server startup. | ||
// | ||
ServerPrxPtr server; | ||
// NOTE: We pass false to the getServer call to indicate that we don't necessarily want an up-to-date adapter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not specifically related to your PR, but where are we passing false
to getServer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the comment refers to the the getProxy
call in getServer(id)->getProxy(false);
|
||
ObjectPrxPtr proxy; | ||
optional<ObjectPrx> proxy; | ||
try | ||
{ | ||
proxy = _database->getObjectProxy(id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should getObjectProxy be updated to not return an optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. This way we know that we are getting non null proxies from the database.
const std::string&, | ||
bool); | ||
~ServerAdapterI() override; | ||
|
||
void activateAsync( | ||
std::function<void(const Ice::ObjectPrxPtr&)>, // TODO: pass by value! | ||
std::function<void(const std::optional<Ice::ObjectPrx>&)>, // TODO: pass by value! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this TODO still relevant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the callback is still taking a reference as before.
} | ||
break; | ||
case Disconnect: | ||
assert(session); | ||
destroySession(session); | ||
destroySession(*session); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we now session is not null here (and below)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous code already has an assert for this.
Ice::Identity id = {"Locator", _database->getInstanceName()}; | ||
return Ice::uncheckedCast<LocatorPrx>(getWellKnownObjectReplicatedProxy(std::move(id), "Client")); | ||
return LocatorPrx{ | ||
getWellKnownObjectReplicatedProxy(Ice::Identity{"Locator", _database->getInstanceName()}, "Client")}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is Ice::Identity required here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, but IMO it is more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but the Slice file doc-comments need some fixes.
// Null observers are ignored | ||
if (observer) | ||
{ | ||
addObserver(*std::move(observer)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uses optional's
constexpr T&& operator*() && noexcept;
@@ -129,7 +129,7 @@ namespace | |||
|
|||
private: | |||
string _id; | |||
ServerPrxPtr _proxy; | |||
optional<ServerPrx> _proxy; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how _proxy can be null. It's just convenience for the constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can fix this by using a helper function, and moving the SynchronizationException
handling to the helper method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try to fix in a follow up PR.
slice/Ice/Locator.ice
Outdated
@@ -87,7 +87,7 @@ interface LocatorRegistry | |||
/// Set the adapter endpoints with the locator registry. | |||
/// @param id The adapter id. | |||
/// @param proxy The adapter proxy (a dummy direct proxy created by the adapter). The direct proxy contains the | |||
/// adapter endpoints. | |||
/// adapter endpoints. The proxy is never null. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is bogus. We pass a null proxy during object adapter deactivation.
@@ -97,19 +97,19 @@ interface LocatorRegistry | |||
/// Set the adapter endpoints with the locator registry. | |||
/// @param adapterId The adapter id. | |||
/// @param replicaGroupId The replica group id. | |||
/// @param p The adapter proxy (a dummy direct proxy created by the adapter). The direct proxy contains the adapter | |||
/// endpoints. | |||
/// @param proxy The adapter proxy (a dummy direct proxy created by the adapter). The direct proxy contains the adapter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be null, see above.
throws AdapterNotFoundException, AdapterAlreadyActiveException, InvalidReplicaGroupIdException; | ||
|
||
/// Set the process proxy for a server. | ||
/// @param id The server id. | ||
/// @param proxy The process proxy. | ||
/// @param proxy The process proxy. The proxy is never null. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is correct - this proxy is never null.
slice/IceGrid/Admin.ice
Outdated
@@ -75,7 +75,7 @@ struct AdapterInfo | |||
/// The id of the adapter. | |||
string id; | |||
|
|||
/// A dummy direct proxy that contains the adapter endpoints. | |||
/// A dummy direct proxy that contains the adapter endpoints. This proxy is never null. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can make this statement for struct fields in general. The application can always put a null proxy in a struct field.
Then, if you look at the Database implementation, this field is occasionally null.
Such information would be more valuable on an operation that accepts or returns an AdapterInfo or AdapterInfoSeq. Like (if accurate) "the proxy field of the returned adapter info is never null".
No description provided.