You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2019/11/14 05:29:14 UTC

[incubator-iotdb] branch master updated (41e7e5f -> 8c2e5e3)

This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.


    from 41e7e5f  Merge remote-tracking branch 'origin/master'
     new 3043acf  [IOTDB-303]fix user profile when online upgrading (#555)
     new 8c2e5e3  remove lost user issue

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 RELEASE_NOTES.md                                      |  1 -
 .../server-changelist.md                              | 12 ++++++++----
 .../iotdb/db/auth/user/LocalFileUserAccessor.java     | 19 +++++++++++++++----
 3 files changed, 23 insertions(+), 9 deletions(-)
 copy tsfile/format-changelist.md => server/server-changelist.md (55%)


[incubator-iotdb] 02/02: remove lost user issue

Posted by qi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit 8c2e5e383a050d8bdbc6dba6835340d3b0b31009
Author: qiaojialin <64...@qq.com>
AuthorDate: Thu Nov 14 13:28:10 2019 +0800

    remove lost user issue
---
 RELEASE_NOTES.md | 1 -
 1 file changed, 1 deletion(-)

diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 484863c..7b575c0 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -94,7 +94,6 @@
 ## Known Issues
 
 * IOTDB-20 Need to support UPDATE
-* IOTDB-303 Lost users information when upgrading 0.8.x to 0.9.0
 
 ## Bug Fixes
 


[incubator-iotdb] 01/02: [IOTDB-303]fix user profile when online upgrading (#555)

Posted by qi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit 3043acff218a1c6566bfa0d61ada708af482af5f
Author: gwmh <16...@qq.com>
AuthorDate: Thu Nov 14 13:26:02 2019 +0800

    [IOTDB-303]fix user profile when online upgrading (#555)
    
    * [fix] upgrade *.profile to 0.9.0
---
 server/server-changelist.md                        | 39 ++++++++++++++++++++++
 .../iotdb/db/auth/user/LocalFileUserAccessor.java  | 19 ++++++++---
 2 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/server/server-changelist.md b/server/server-changelist.md
new file mode 100644
index 0000000..3893f62
--- /dev/null
+++ b/server/server-changelist.md
@@ -0,0 +1,39 @@
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+    
+        http://www.apache.org/licenses/LICENSE-2.0
+    
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+
+# 0.8.0 (version-0) -> version-1
+
+## User profile
+Last Updated on November 14th, 2019 by EJTTianYu.
+
+| PR#   | Name                                                         | Author          | Changes                                                      |
+| ---- | ------------------------------------------------------------ | --------------- | ------------------------------------------------------------ |
+| 299  | Turn watermark-demo into watermark feature                   | LeiRui          | Add watermark in the end of the profile.                     |
+
+## Upgrading Log
+Last Updated on November 14th, 2019 by EJTTianYu.
+
+| PR#   | Name                                                         | Author          | Changes                                                      |
+| ---- | ------------------------------------------------------------ | --------------- | ------------------------------------------------------------ |
+| 467  | [IOTDB-294]online upgrade from v0.8.0 to current version     | EJTTianYu       | Add upgrade/upgrade.txt in the system dir to record the upgrading process.     |
+
+
+
diff --git a/server/src/main/java/org/apache/iotdb/db/auth/user/LocalFileUserAccessor.java b/server/src/main/java/org/apache/iotdb/db/auth/user/LocalFileUserAccessor.java
index 6946a86..88ffd74 100644
--- a/server/src/main/java/org/apache/iotdb/db/auth/user/LocalFileUserAccessor.java
+++ b/server/src/main/java/org/apache/iotdb/db/auth/user/LocalFileUserAccessor.java
@@ -78,7 +78,7 @@ public class LocalFileUserAccessor implements IUserAccessor {
       File newProfile = SystemFileFactory.INSTANCE.getFile(
           userDirPath + File.separator + username + IoTDBConstant.PROFILE_SUFFIX + TEMP_SUFFIX);
       if (newProfile.exists() && newProfile.isFile()) {
-        if(!newProfile.renameTo(userProfile)) {
+        if (!newProfile.renameTo(userProfile)) {
           logger.error("New profile renaming not succeed.");
         }
         userProfile = newProfile;
@@ -106,7 +106,17 @@ public class LocalFileUserAccessor implements IUserAccessor {
         roleList.add(userName);
       }
       user.setRoleList(roleList);
-      user.setUseWaterMark(dataInputStream.readInt() != 0);
+
+      // for online upgrading, profile for 0.8.x does not contain waterMark
+      try {
+        user.setUseWaterMark(dataInputStream.readInt() != 0);
+      } catch (EOFException e1) {
+        user.setUseWaterMark(false);
+        try (RandomAccessFile file = new RandomAccessFile(userProfile, "rw")) {
+          file.seek(file.length());
+          file.writeInt(0);
+        }
+      }
       return user;
     } catch (Exception e) {
       throw new IOException(e);
@@ -122,7 +132,8 @@ public class LocalFileUserAccessor implements IUserAccessor {
   public void saveUser(User user) throws IOException {
     File userProfile = SystemFileFactory.INSTANCE.getFile(
         userDirPath + File.separator + user.getName() + IoTDBConstant.PROFILE_SUFFIX + TEMP_SUFFIX);
-    try(BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(userProfile))) {
+    try (BufferedOutputStream outputStream = new BufferedOutputStream(
+        new FileOutputStream(userProfile))) {
       try {
         IOUtils.writeString(outputStream, user.getName(), STRING_ENCODING, encodingBufferLocal);
         IOUtils.writeString(outputStream, user.getPassword(), STRING_ENCODING, encodingBufferLocal);
@@ -144,7 +155,7 @@ public class LocalFileUserAccessor implements IUserAccessor {
               .writeString(outputStream, user.getRoleList().get(i), STRING_ENCODING,
                   encodingBufferLocal);
         }
-        IOUtils.writeInt(outputStream, user.isUseWaterMark()? 1 : 0, encodingBufferLocal);
+        IOUtils.writeInt(outputStream, user.isUseWaterMark() ? 1 : 0, encodingBufferLocal);
         outputStream.flush();
 
       } catch (Exception e) {