Skip to content

Commit

Permalink
Sync protofiles & remove heartbeat
Browse files Browse the repository at this point in the history
  • Loading branch information
gartens committed Apr 10, 2024
1 parent 38d8e30 commit bc14ec8
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ public ClientManager( PIPlugin.ProtoInterface protoInterface ) {
this.clients = new ConcurrentHashMap<>();
this.authenticator = protoInterface.getAuthenticator();
this.transactionManager = protoInterface.getTransactionManager();
if ( protoInterface.isRequiresHeartbeat() ) {
this.heartbeatInterval = protoInterface.getHeartbeatInterval();
this.cleanupTimer = new Timer();
cleanupTimer.schedule( createNewCleanupTask(), 0, heartbeatInterval + HEARTBEAT_TOLERANCE );
}
this.heartbeatInterval = 0;
this.monitoringPage = protoInterface.getMonitoringPage();
monitoringPage.setClientManager( this );
}
Expand Down Expand Up @@ -169,22 +163,4 @@ public PIClient getClient( String clientUUID ) throws PIServiceException {
return clients.get( clientUUID );
}


private TimerTask createNewCleanupTask() {
Runnable runnable = this::unregisterInactiveClients;
return new TimerTask() {
@Override
public void run() {
runnable.run();
}
};
}


private void unregisterInactiveClients() {
List<PIClient> inactiveClients = clients.values().stream()
.filter( c -> !c.returnAndResetIsActive() ).toList();
inactiveClients.forEach( this::unregisterConnection );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,12 @@ public static class ProtoInterface extends QueryInterface implements PropertyCha
public static final String INTERFACE_NAME = "Proto Interface";
public static final String INTERFACE_DESCRIPTION = "proto-interface query interface supporting the PolySQL dialect.";
public static final List<QueryInterfaceSetting> AVAILABLE_PLAIN_SETTINGS = ImmutableList.of(
new QueryInterfaceSettingInteger( "port", false, true, false, 20590 ),
new QueryInterfaceSettingBoolean( "requires heartbeat", false, true, false, false ),
new QueryInterfaceSettingLong( "heartbeat interval", false, true, false, 300000L )
new QueryInterfaceSettingInteger( "port", false, true, false, 20590 )
);
public static final List<QueryInterfaceSetting> AVAILABLE_UNIX_SETTINGS = ImmutableList.of(
new QueryInterfaceSettingString( "path", false, true, false, "polypheny-prism.sock" )
);

@Getter
private final boolean requiresHeartbeat;
@Getter
private final long heartbeatInterval;
@Getter
private final TransactionManager transactionManager;
@Getter
Expand All @@ -91,21 +85,14 @@ enum Transport {
}


private Transport transport;
private final Transport transport;


private ProtoInterface( TransactionManager transactionManager, Authenticator authenticator, String uniqueName, Transport transport, Map<String, String> settings ) {
super( transactionManager, authenticator, uniqueName, settings, true, true );
this.authenticator = authenticator;
this.transactionManager = transactionManager;
this.transport = transport;
if ( getAvailableSettings().stream().anyMatch( s -> s.name.equals( "requires heartbeat" ) ) ) {
this.requiresHeartbeat = Boolean.getBoolean( settings.get( "requires heartbeat" ) );
this.heartbeatInterval = Long.parseLong( settings.get( "heartbeat interval" ) );
} else {
this.requiresHeartbeat = false;
this.heartbeatInterval = 0;
}
this.monitoringPage = new MonitoringPage( uniqueName, INTERFACE_NAME );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ message ConnectionResponse {
int32 major_api_version = 2;
// The minor version number of the server’s API. Provides finer granularity about the server’s capabilities.
int32 minor_api_version = 3;
/*
Specifies the interval in milliseconds at which the client should send heartbeat signals to maintain the connection.
If not provided, the connection does not require a heartbeat to remain valid.
*/
optional int64 heartbeat_interval = 4;
}

/*
Expand Down

0 comments on commit bc14ec8

Please sign in to comment.