[
https://issues.apache.org/jira/browse/KYLIN-3562?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16666817#comment-16666817
]
ASF GitHub Bot commented on KYLIN-3562:
---------------------------------------
shaofengshi closed pull request #317: KYLIN-3562, optimization the logic that
updating the user when user logged in.
URL: https://github.com/apache/kylin/pull/317
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/server-base/src/main/java/org/apache/kylin/rest/security/KylinAuthenticationProvider.java
b/server-base/src/main/java/org/apache/kylin/rest/security/KylinAuthenticationProvider.java
index dd9cbad0a8..d96b3583de 100644
---
a/server-base/src/main/java/org/apache/kylin/rest/security/KylinAuthenticationProvider.java
+++
b/server-base/src/main/java/org/apache/kylin/rest/security/KylinAuthenticationProvider.java
@@ -110,10 +110,12 @@ public Authentication authenticate(Authentication
authentication) throws Authent
}
Assert.notNull(user, "The UserDetail is null.");
- logger.debug("User {} authorities : {}", user.getUsername(),
user.getAuthorities());
- if (!userService.userExists(user.getUsername())) {
+ String username = user.getUsername();
+ logger.debug("User {} authorities : {}", username,
user.getAuthorities());
+ if (!userService.userExists(username)) {
userService.createUser(user);
- } else {
+ } else if
(!userService.loadUserByUsername(username).equals(user)) {
+ // in case ldap users changing.
userService.updateUser(user);
}
diff --git
a/server-base/src/main/java/org/apache/kylin/rest/security/ManagedUser.java
b/server-base/src/main/java/org/apache/kylin/rest/security/ManagedUser.java
index 00e0045357..48d44405a1 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/security/ManagedUser.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/security/ManagedUser.java
@@ -22,8 +22,8 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import java.util.Objects;
-import com.google.common.base.Preconditions;
import org.apache.kylin.common.persistence.RootPersistentEntity;
import org.apache.kylin.rest.service.UserGrantedAuthority;
import org.springframework.security.core.GrantedAuthority;
@@ -41,6 +41,7 @@
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
@SuppressWarnings("serial")
@@ -231,28 +232,22 @@ public boolean isEnabled() {
}
@Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((username == null) ? 0 :
username.hashCode());
- return result;
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ ManagedUser that = (ManagedUser) o;
+ return disabled == that.disabled && defaultPassword ==
that.defaultPassword && locked == that.locked
+ && lockedTime == that.lockedTime && wrongTime == that.wrongTime
+ && Objects.equals(username, that.username) &&
Objects.equals(password, that.password)
+ && Objects.equals(authorities, that.authorities);
}
@Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ManagedUser other = (ManagedUser) obj;
- if (username == null) {
- if (other.username != null)
- return false;
- } else if (!username.equals(other.username))
- return false;
- return true;
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), username, password, authorities,
disabled, defaultPassword, locked,
+ lockedTime, wrongTime);
}
@Override
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> TS conflict when kylin update metadata in HBase
> -----------------------------------------------
>
> Key: KYLIN-3562
> URL: https://issues.apache.org/jira/browse/KYLIN-3562
> Project: Kylin
> Issue Type: Bug
> Affects Versions: v2.4.0
> Reporter: Lingang Deng
> Assignee: Jiatao Tao
> Priority: Major
> Fix For: v2.4.2, v2.5.1
>
> Attachments: image-2018-09-17-16-40-56-212.png,
> image-2018-09-25-15-03-51-009.png, image-2018-09-25-16-43-50-277.png
>
>
> Error log was as follows,
> {code:java}
> org.apache.kylin.common.persistence.WriteConflictException: Overwriting
> conflict /user/admin, expect old TS 1536928877043, but it is 1536928907207
> at
> org.apache.kylin.storage.hbase.HBaseResourceStore.checkAndPutResourceImpl(HBaseResourceStore.java:325)
> at
> org.apache.kylin.common.persistence.ResourceStore.checkAndPutResourceCheckpoint(ResourceStore.java:318)
> at
> org.apache.kylin.common.persistence.ResourceStore.putResource(ResourceStore.java:303)
> at
> org.apache.kylin.common.persistence.ResourceStore.putResource(ResourceStore.java:282)
> at
> org.apache.kylin.metadata.cachesync.CachedCrudAssist.save(CachedCrudAssist.java:192){code}
>
> what disturbs me the most was that the error was happened several hours,
> then my all build job and query job failed.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)