usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mru...@apache.org
Subject usergrid git commit: Fix issue where tokenInfo was not being updated with latest inactive value. Add trace logging to TokenSerializationImpl. Fix issue with push notifications where the InactiveDeviceManager was making a duplicate (yet incorrect) query f
Date Sun, 18 Jun 2017 19:37:53 GMT
Repository: usergrid
Updated Branches:
  refs/heads/token-service-to-dstax 146e47d66 -> bea9a4180


Fix issue where tokenInfo was not being updated with latest inactive value. Add trace logging
to TokenSerializationImpl. Fix issue with push notifications where the InactiveDeviceManager
was making a duplicate (yet incorrect) query for devices.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/bea9a418
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/bea9a418
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/bea9a418

Branch: refs/heads/token-service-to-dstax
Commit: bea9a4180ebadb79e7f101cfc6d0d06efc39b359
Parents: 146e47d
Author: Michael Russo <russomichael@google.com>
Authored: Sun Jun 18 12:36:56 2017 -0700
Committer: Michael Russo <russomichael@google.com>
Committed: Sun Jun 18 12:36:56 2017 -0700

----------------------------------------------------------------------
 .../token/impl/TokenSerializationImpl.java      | 35 ++++++++++++++------
 .../security/tokens/impl/TokenServiceImpl.java  |  9 +++--
 .../notifications/InactiveDeviceManager.java    |  6 ----
 3 files changed, 31 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/bea9a418/stack/corepersistence/token/src/main/java/org/apache/usergrid/persistence/token/impl/TokenSerializationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/token/src/main/java/org/apache/usergrid/persistence/token/impl/TokenSerializationImpl.java
b/stack/corepersistence/token/src/main/java/org/apache/usergrid/persistence/token/impl/TokenSerializationImpl.java
index 2207b99..240da00 100644
--- a/stack/corepersistence/token/src/main/java/org/apache/usergrid/persistence/token/impl/TokenSerializationImpl.java
+++ b/stack/corepersistence/token/src/main/java/org/apache/usergrid/persistence/token/impl/TokenSerializationImpl.java
@@ -130,22 +130,27 @@ public class TokenSerializationImpl implements TokenSerialization {
     public void deleteTokens(final List<UUID> tokenUUIDs, final ByteBuffer principalKeyBuffer){
 
         Preconditions.checkNotNull(tokenUUIDs, "token UUID list is required");
+        Preconditions.checkNotNull(tokenUUIDs, "principalKeyBuffer is required");
 
-        final BatchStatement batchStatement = new BatchStatement();
+        logger.trace("deleteTokens, token UUIDs: {}", tokenUUIDs);
 
-        tokenUUIDs.forEach( tokenUUID -> batchStatement.add(
-        QueryBuilder.delete()
-            .from(TOKENS_TABLE)
-            .where(QueryBuilder
-                .eq("key", DataType.uuid().serialize(tokenUUID, ProtocolVersion.NEWEST_SUPPORTED)))));
+        final BatchStatement batchStatement = new BatchStatement();
 
-        if(principalKeyBuffer != null){
+        tokenUUIDs.forEach( tokenUUID ->
             batchStatement.add(
                 QueryBuilder.delete()
-                    .from(PRINCIPAL_TOKENS_TABLE)
+                    .from(TOKENS_TABLE)
                     .where(QueryBuilder
-                        .eq("key", principalKeyBuffer)));
-        }
+                        .eq("key", DataType.uuid().serialize(tokenUUID, ProtocolVersion.NEWEST_SUPPORTED)))
+            )
+        );
+
+        batchStatement.add(
+            QueryBuilder.delete()
+                .from(PRINCIPAL_TOKENS_TABLE)
+                .where(QueryBuilder
+                    .eq("key", principalKeyBuffer)));
+
 
         session.execute(batchStatement);
 
@@ -157,6 +162,9 @@ public class TokenSerializationImpl implements TokenSerialization {
 
         Preconditions.checkNotNull(tokenUUID, "token UUID is required");
 
+        logger.trace("revokeToken, token UUID: {}", tokenUUID);
+
+
         final BatchStatement batchStatement = new BatchStatement();
 
         batchStatement.add(
@@ -188,6 +196,8 @@ public class TokenSerializationImpl implements TokenSerialization {
         Preconditions.checkNotNull(inactiveTime, "inactiveTime is required");
         Preconditions.checkNotNull(ttl, "ttl is required");
 
+        logger.trace("updateTokenAccessTime, token UUID: {}, accessedTime: {}, inactiveTime:
{}, ttl: {}",
+            tokenUUID, accessedTime, inactiveTime, ttl);
 
         final BatchStatement batchStatement = new BatchStatement();
         final Clause inKey =
@@ -265,6 +275,8 @@ public class TokenSerializationImpl implements TokenSerialization {
 
         });
 
+        logger.trace("getTokenInfo, info: {}", tokenInfo);
+
         return tokenInfo;
     }
 
@@ -277,6 +289,7 @@ public class TokenSerializationImpl implements TokenSerialization {
         Preconditions.checkNotNull(tokenUUID, "tokenInfo is required");
         Preconditions.checkNotNull(ttl, "ttl is required");
 
+        logger.trace("putTokenInfo, token UUID: {}, tokenInfo: {}, ttl: {}", tokenUUID, tokenInfo,
ttl);
 
         final BatchStatement batchStatement = new BatchStatement();
         final Using usingTTL = QueryBuilder.ttl(ttl);
@@ -332,6 +345,8 @@ public class TokenSerializationImpl implements TokenSerialization {
 
         rows.forEach(row -> tokenUUIDs.add(row.getUUID("column1")));
 
+        logger.trace("getTokensForPrincipal, token UUIDs: {}", tokenUUIDs);
+
         return tokenUUIDs;
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/bea9a418/stack/services/src/main/java/org/apache/usergrid/security/tokens/impl/TokenServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/security/tokens/impl/TokenServiceImpl.java
b/stack/services/src/main/java/org/apache/usergrid/security/tokens/impl/TokenServiceImpl.java
index d93ecc0..21bd0db 100644
--- a/stack/services/src/main/java/org/apache/usergrid/security/tokens/impl/TokenServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/security/tokens/impl/TokenServiceImpl.java
@@ -310,9 +310,12 @@ public class TokenServiceImpl implements TokenService {
             long maxTokenTtl = getMaxTtl(TokenCategory.getFromBase64String(token), tokenInfo.getPrincipal());
 
             long inactive = now - tokenInfo.getAccessed();
-            // Long.MIN_VALUE indicates that nothing needs to be updated for token inactive
property
-            if (inactive < tokenInfo.getInactive()) {
-               inactive = Long.MIN_VALUE;
+            if (inactive > tokenInfo.getInactive()) {
+                tokenInfo.setInactive(inactive);
+            }else{
+                // Long.MIN_VALUE indicates that nothing needs to be updated for token inactive
property in
+                // tokenSerialization.updateTokenAccessTime()
+                inactive = Long.MIN_VALUE;
             }
 
             tokenSerialization.updateTokenAccessTime(uuid, now, inactive, calcTokenTime(tokenInfo.getExpiration(maxTokenTtl)));

http://git-wip-us.apache.org/repos/asf/usergrid/blob/bea9a418/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
b/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
index 37650c5..6693939 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
@@ -64,12 +64,6 @@ public class InactiveDeviceManager {
                     for (Entity e : results.getEntities()) {
                         entityManager.updateProperties(e, clearPushtokenMap);
                     }
-                    // uuid
-                    query = Query.fromQL( notifier.getName() + notfierPostFix  + " = " +
entry.getKey() + "");
-                    results = entityManager.searchCollection(entityManager.getApplication(),
 "devices", query);
-                    for (Entity e : results.getEntities()) {
-                        entityManager.updateProperties(e, clearPushtokenMap);
-                    }
                 }catch (Exception e){
                     logger.error("failed to remove token",e);
                 }


Mime
View raw message