|
|
@ -337,23 +337,24 @@ public class TbLwM2mRedisRegistrationStore implements CaliforniumRegistrationSto |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//TODO: JedisCluster didn't implement Transaction, maybe should use some advanced key creation strategies
|
|
|
private void removeAddrIndex(RedisConnection connection, Registration registration) { |
|
|
private void removeAddrIndex(RedisConnection connection, Registration registration) { |
|
|
// Watch the key to remove.
|
|
|
// Watch the key to remove.
|
|
|
byte[] regAddrKey = toRegAddrKey(registration.getSocketAddress()); |
|
|
byte[] regAddrKey = toRegAddrKey(registration.getSocketAddress()); |
|
|
connection.watch(regAddrKey); |
|
|
// connection.watch(regAddrKey);
|
|
|
|
|
|
|
|
|
byte[] epFromAddr = connection.get(regAddrKey); |
|
|
byte[] epFromAddr = connection.get(regAddrKey); |
|
|
// Delete the key if needed.
|
|
|
// Delete the key if needed.
|
|
|
if (Arrays.equals(epFromAddr, registration.getEndpoint().getBytes(UTF_8))) { |
|
|
if (Arrays.equals(epFromAddr, registration.getEndpoint().getBytes(UTF_8))) { |
|
|
// Try to delete the key
|
|
|
// Try to delete the key
|
|
|
connection.multi(); |
|
|
// connection.multi();
|
|
|
connection.del(regAddrKey); |
|
|
connection.del(regAddrKey); |
|
|
connection.exec(); |
|
|
// connection.exec();
|
|
|
// if transaction failed this is not an issue as the socket address is probably reused and we don't neeed to
|
|
|
// if transaction failed this is not an issue as the socket address is probably reused and we don't neeed to
|
|
|
// delete it anymore.
|
|
|
// delete it anymore.
|
|
|
} else { |
|
|
} else { |
|
|
// the key must not be deleted.
|
|
|
// the key must not be deleted.
|
|
|
connection.unwatch(); |
|
|
// connection.unwatch();
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|