@@ -34,22 +34,25 @@ void TreeOperations::getDatabases(std::function<void (RedisClient::DatabaseList)
3434
3535 RedisClient::DatabaseList availableDatabeses = m_connection->getKeyspaceInfo ();
3636
37- // detect all databases
38- RedisClient::Response scanningResp;
39- int dbIndex = (availableDatabeses.size () == 0 )? 0 : availableDatabeses.lastKey () + 1 ;
40-
41- while (true ) {
42- try {
43- scanningResp = m_connection->commandSync (" select" , QString::number (dbIndex));
44- } catch (const RedisClient::Connection::Exception& e) {
45- throw ConnectionsTree::Operations::Exception (QObject::tr (" Connection error: " ) + QString (e.what ()));
37+ if (m_connection->mode () != RedisClient::Connection::Mode::Cluster) {
38+ // detect all databases
39+ RedisClient::Response scanningResp;
40+ int dbIndex = (availableDatabeses.size () == 0 )? 0 : availableDatabeses.lastKey () + 1 ;
41+
42+ while (true ) {
43+ try {
44+ scanningResp = m_connection->commandSync (" select" , QString::number (dbIndex));
45+ } catch (const RedisClient::Connection::Exception& e) {
46+ throw ConnectionsTree::Operations::Exception (QObject::tr (" Connection error: " ) + QString (e.what ()));
47+ }
48+
49+ if (!scanningResp.isOkMessage ())
50+ break ;
51+
52+ availableDatabeses.insert (dbIndex, 0 );
53+ ++dbIndex;
4654 }
4755
48- if (!scanningResp.isOkMessage ())
49- break ;
50-
51- availableDatabeses.insert (dbIndex, 0 );
52- ++dbIndex;
5356 }
5457
5558 emit m_manager.openServerStats (m_connection);
@@ -63,7 +66,11 @@ void TreeOperations::getDatabaseKeys(uint dbIndex, QString filter,
6366 QString keyPattern = filter.isEmpty () ? static_cast <ServerConfig>(m_connection->getConfig ()).keysPattern () : filter;
6467
6568 try {
66- m_connection->getDatabaseKeys (callback, keyPattern, dbIndex);
69+ if (m_connection->mode () == RedisClient::Connection::Mode::Cluster) {
70+ m_connection->getClusterKeys (callback, keyPattern);
71+ } else {
72+ m_connection->getDatabaseKeys (callback, keyPattern, dbIndex);
73+ }
6774 } catch (const RedisClient::Connection::Exception& error) {
6875 callback (RedisClient::Connection::RawKeysList (), QString (QObject::tr (" Cannot load keys: %1" )).arg (error.what ()));
6976 }
@@ -153,3 +160,14 @@ void TreeOperations::flushDb(int dbIndex, std::function<void(const QString&)> ca
153160 throw ConnectionsTree::Operations::Exception (QObject::tr (" FlushDB error: " ) + QString (e.what ()));
154161 }
155162}
163+
164+ QString TreeOperations::mode ()
165+ {
166+ if (m_connection->mode () == RedisClient::Connection::Mode::Cluster) {
167+ return QString (" cluster" );
168+ } else if (m_connection->mode () == RedisClient::Connection::Mode::Sentinel) {
169+ return QString (" sentinel" );
170+ } else {
171+ return QString (" standalone" );
172+ }
173+ }
0 commit comments