Skip to content

Commit

Permalink
Merge branch 'main' into nested-proxy-props
Browse files Browse the repository at this point in the history
  • Loading branch information
externl authored Oct 23, 2024
2 parents 4c66bc0 + e7e0cbb commit 003c452
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 24 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"[java]": {
"editor.defaultFormatter": "josevseb.google-java-format-for-vs-code"
},
"netbeans.java.onSave.organizeImports": false, // This breaks google-java-format ordering
"java.format.settings.google.extra": "--aosp",
"java.format.settings.google.version": "1.24.0", // should match version in ice.gradle
"gradle.nestedProjects": true,
Expand Down
3 changes: 3 additions & 0 deletions config/PropertyNames.xml
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,14 @@
<property name="Registry.DynamicRegistration" languages="cpp" />
<property name="Registry.Internal" class="ObjectAdapter" languages="cpp" />
<property name="Registry.LMDB" class="LMDB" languages="cpp"/>
<property name="Registry.NodeSessionTimeout" languages="cpp" default="30" />
<property name="Registry.PermissionsVerifier" class="Proxy" languages="cpp" />
<property name="Registry.ReplicaName" languages="cpp" default="Master" />
<property name="Registry.ReplicaSessionTimeout" languages="cpp" default="30" />
<property name="Registry.Server" class="ObjectAdapter" languages="cpp" />
<property name="Registry.SessionFilters" languages="cpp" default="0" />
<property name="Registry.SessionManager" class="ObjectAdapter" languages="cpp" />
<property name="Registry.SessionTimeout" languages="cpp" default="30" />
<property name="Registry.SSLPermissionsVerifier" class="Proxy" languages="cpp"/>
<property name="Registry.Trace.Admin" languages="cpp" default="0" />
<property name="Registry.Trace.Application" languages="cpp" default="0" />
Expand Down
5 changes: 4 additions & 1 deletion cpp/src/Ice/PropertyNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,14 @@ const Property IceGridPropsData[] =
Property{"Registry.DynamicRegistration", "", false, false, nullptr},
Property{"Registry.Internal", "", false, false, &PropertyNames::ObjectAdapterProps},
Property{"Registry.LMDB", "", false, false, &PropertyNames::LMDBProps},
Property{"Registry.NodeSessionTimeout", "30", false, false, nullptr},
Property{"Registry.PermissionsVerifier", "", false, false, &PropertyNames::ProxyProps},
Property{"Registry.ReplicaName", "Master", false, false, nullptr},
Property{"Registry.ReplicaSessionTimeout", "30", false, false, nullptr},
Property{"Registry.Server", "", false, false, &PropertyNames::ObjectAdapterProps},
Property{"Registry.SessionFilters", "0", false, false, nullptr},
Property{"Registry.SessionManager", "", false, false, &PropertyNames::ObjectAdapterProps},
Property{"Registry.SessionTimeout", "30", false, false, nullptr},
Property{"Registry.SSLPermissionsVerifier", "", false, false, &PropertyNames::ProxyProps},
Property{"Registry.Trace.Admin", "0", false, false, nullptr},
Property{"Registry.Trace.Application", "0", false, false, nullptr},
Expand All @@ -402,7 +405,7 @@ const PropertyArray PropertyNames::IceGridProps
"IceGrid",
false,
IceGridPropsData,
60
63
};

const Property IceSSLPropsData[] =
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/IceGrid/AdminSessionI.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace IceGrid

Ice::ObjectPrx _register(const std::shared_ptr<SessionServantManager>&, const Ice::ConnectionPtr&);

// keepAlive is deprecated and kept only for compatibility with old clients. It does nothing now.
void keepAlive(const Ice::Current&) override {}
void keepAlive(const Ice::Current& current) override { BaseSessionI::keepAlive(current); }

std::optional<AdminPrx> getAdmin(const Ice::Current&) const override;
std::optional<Ice::ObjectPrx> getAdminCallbackTemplate(const Ice::Current&) const override;
Expand Down
5 changes: 2 additions & 3 deletions cpp/src/IceGrid/InternalRegistryI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ InternalRegistryI::InternalRegistryI(
_session(session)
{
auto properties = database->getCommunicator()->getProperties();
// TODO: temporary. For now, synchronized with the default idle timeout.
_nodeSessionTimeout = chrono::seconds(60);
_replicaSessionTimeout = chrono::seconds(60);
_nodeSessionTimeout = chrono::seconds(properties->getIcePropertyAsInt("IceGrid.Registry.NodeSessionTimeout"));
_replicaSessionTimeout = chrono::seconds(properties->getIcePropertyAsInt("IceGrid.Registry.ReplicaSessionTimeout"));
}

optional<NodeSessionPrx>
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/IceGrid/RegistryI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ RegistryI::startImpl()
_replicaName = properties->getIceProperty("IceGrid.Registry.ReplicaName");
_master = _replicaName == "Master";

// TODO: temporary. For now, synchronized with the default idle timeout.
_sessionTimeout = chrono::seconds(60);
_sessionTimeout = chrono::seconds(properties->getIcePropertyAsInt("IceGrid.Registry.SessionTimeout"));

if (!_initFromReplica.empty() && (_initFromReplica == _replicaName || (_master && _initFromReplica == "Master")))
{
Expand Down
18 changes: 18 additions & 0 deletions cpp/src/IceGrid/SessionI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@ BaseSessionI::BaseSessionI(const string& id, const string& prefix, const shared_
}
}

void
BaseSessionI::keepAlive(const Ice::Current&)
{
lock_guard lock(_mutex);
if (_destroyed)
{
throw Ice::ObjectNotExistException{__FILE__, __LINE__};
}

_timestamp = chrono::steady_clock::now();

if (_traceLevels->session > 1)
{
Ice::Trace out(_traceLevels->logger, _traceLevels->sessionCat);
out << _prefix << " session '" << _id << "' keep alive";
}
}

void
BaseSessionI::destroyImpl(bool)
{
Expand Down
5 changes: 3 additions & 2 deletions cpp/src/IceGrid/SessionI.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ namespace IceGrid
public:
virtual ~BaseSessionI() = default;

virtual void keepAlive(const Ice::Current&);

std::chrono::steady_clock::time_point timestamp() const;
void shutdown();
std::optional<Glacier2::IdentitySetPrx> getGlacier2IdentitySet();
Expand Down Expand Up @@ -57,8 +59,7 @@ namespace IceGrid

Ice::ObjectPrx _register(const std::shared_ptr<SessionServantManager>&, const Ice::ConnectionPtr&);

// keepAlive is deprecated and kept only for compatibility with old clients. It does nothing now.
void keepAlive(const Ice::Current&) final {}
void keepAlive(const Ice::Current& current) final { BaseSessionI::keepAlive(current); }
void allocateObjectByIdAsync(
Ice::Identity id,
std::function<void(const std::optional<Ice::ObjectPrx>& returnValue)> response,
Expand Down
1 change: 1 addition & 0 deletions cpp/test/IceGrid/replication/application.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<property name="IceGrid.Registry.PermissionsVerifier" value="RepTestIceGrid/NullPermissionsVerifier"/>
<property name="IceGrid.Registry.SSLPermissionsVerifier" value="RepTestIceGrid/NullSSLPermissionsVerifier"/>
<property name="IceGrid.Registry.AdminPermissionsVerifier" value="RepTestIceGrid/NullPermissionsVerifier"/>
<property name="IceGrid.Registry.SessionTimeout" value="0"/>
<property name="IceGrid.Registry.DynamicRegistration" value="1"/>
<property name="Ice.Default.Locator" value="RepTestIceGrid/Locator:default -p 12050:default -p 12051:default -p 12052"/>
<property name="IceGrid.Registry.Trace.Replica" value="1"/>
Expand Down
3 changes: 0 additions & 3 deletions java/gradle/ice.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ spotless {
}
}

// Run spotlessApply before compiling Java code
compileJava.dependsOn 'spotlessApply'

// Android does not have a compileJava task
if(!(project.hasProperty('android') && project.android.sourceSets)) {
compileJava {
Expand Down
18 changes: 11 additions & 7 deletions java/src/Ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1090,19 +1090,21 @@ public int messageSizeMax() {

final Properties properties = _instance.initializationData().properties;

Properties.validatePropertiesWithPrefix(
_name, properties, PropertyNames.ObjectAdapterProps);
try {
Properties.validatePropertiesWithPrefix(
_name, properties, PropertyNames.ObjectAdapterProps);
} catch (UnknownPropertyException ex) {
// Prevent finalizer from complaining about the adapter not being destroyed.
_state = StateDestroyed;
throw ex;
}

//
// Make sure named adapter has some configuration.
//
if (router == null && properties.getPropertiesForPrefix(_name).isEmpty()) {
//
// These need to be set to prevent finalizer from complaining.
//
// Prevent finalizer from complaining about the adapter not being destroyed.
_state = StateDestroyed;
_instance = null;
_incomingConnectionFactories = null;

throw new InitializationException(
"Object adapter '" + _name + "' requires configuration.");
Expand All @@ -1119,6 +1121,8 @@ public int messageSizeMax() {
try {
_reference = _instance.referenceFactory().create("dummy " + proxyOptions, "");
} catch (ParseException ex) {
// Prevent finalizer from complaining about the adapter not being destroyed.
_state = StateDestroyed;
throw new InitializationException(
"invalid proxy options '"
+ proxyOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ com.zeroc.Ice.Object removeCallback(String name, String facet) {
}

void close(boolean destroySession) {
if (_keepAliveFuture != null) {
_keepAliveFuture.cancel(false);
_keepAliveFuture = null;
}

if (_adapter != null) {
_adapter.destroy();
_adapter = null;
Expand Down Expand Up @@ -371,6 +376,8 @@ public void registerObservers() throws Throwable {
private final AdminSessionPrx _session;
private final boolean _routed;

private java.util.concurrent.Future<?> _keepAliveFuture;

private com.zeroc.Ice.ObjectAdapter _adapter;
private AdminPrx _admin;
private String _serverAdminCategory;
Expand Down
1 change: 1 addition & 0 deletions scripts/IceGridUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def getProps(self, current):
"IceGrid.Registry.Discovery.Port": current.driver.getTestPort(99),
"IceGrid.Registry.SessionManager.Endpoints": "default",
"IceGrid.Registry.AdminSessionManager.Endpoints": "default",
"IceGrid.Registry.SessionTimeout": 60,
"IceGrid.Registry.ReplicaName": self.name,
"Ice.ProgramName": self.name,
"Ice.PrintAdapterReady": 1,
Expand Down
5 changes: 3 additions & 2 deletions slice/IceGrid/Admin.ice
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,9 @@ module IceGrid
/// @see Registry
interface AdminSession extends Glacier2::Session
{
/// Keep the session alive. This operation is provided for backwards compatibility. As of Ice 3.8, there is no
/// need to call this operation and its implementation does nothing.
/// Keep the session alive. Clients should call this operation regularly to prevent the server from reaping the
/// session.
/// @see Registry#getSessionTimeout
idempotent void keepAlive();

/// Get the admin interface. The admin object returned by this operation can only be accessed by the session.
Expand Down
5 changes: 3 additions & 2 deletions slice/IceGrid/Session.ice
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ module IceGrid
/// @see Registry
interface Session extends Glacier2::Session
{
/// Keep the session alive. This operation is provided for backwards compatibility. As of Ice 3.8, there is no
/// need to call this operation and its implementation does nothing.
/// Keep the session alive. Clients should call this operation regularly to prevent the server from reaping the
/// session.
/// @see Registry#getSessionTimeout
idempotent void keepAlive();

/// Allocate an object. Depending on the allocation timeout, this operation might hang until the object is
Expand Down

0 comments on commit 003c452

Please sign in to comment.