You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by ya...@apache.org on 2021/03/05 02:57:09 UTC
[incubator-doris] 02/02: [Bug] Fix bug that the image cannot be
pulled after the new fe nodes added (#5418)
This is an automated email from the ASF dual-hosted git repository.
yangzhg pushed a commit to branch branch-0.14
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit 48444ae9fcdcc1981a8ae0a34d6d241e9a7822a9
Author: Mingyu Chen <mo...@gmail.com>
AuthorDate: Fri Mar 5 10:50:54 2021 +0800
[Bug] Fix bug that the image cannot be pulled after the new fe nodes added (#5418)
* [Bug] Fix bug that the image cannot be pulled after the new fe node is added
This is because httpv2 modified the response body of the "/info" api,
causing FE to fail to obtain info from this api.
And the system did not exit correctly.
This will also cause issues in issue #5292
(cherry picked from commit c95f00d5081082d328fa857b49a8bd0b58404611)
---
.../java/org/apache/doris/catalog/Catalog.java | 26 +++++++++++++++++--
.../org/apache/doris/persist/StorageInfoV2.java | 30 ++++++++++++++++++++++
2 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
index 7ea431f..200f9d3 100755
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
@@ -185,6 +185,7 @@ import org.apache.doris.persist.ReplicaPersistInfo;
import org.apache.doris.persist.SetReplicaStatusOperationLog;
import org.apache.doris.persist.Storage;
import org.apache.doris.persist.StorageInfo;
+import org.apache.doris.persist.StorageInfoV2;
import org.apache.doris.persist.TableInfo;
import org.apache.doris.persist.TablePropertyInfo;
import org.apache.doris.persist.TruncateTableInfo;
@@ -236,12 +237,14 @@ import org.apache.logging.log4j.Logger;
import org.codehaus.jackson.map.ObjectMapper;
import java.io.BufferedInputStream;
+import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
@@ -1394,7 +1397,7 @@ public class Catalog {
MetaHelper.complete(filename, dir);
}
} catch (Exception e) {
- return;
+ throw new IOException(e);
}
}
@@ -1425,7 +1428,26 @@ public class Catalog {
connection = (HttpURLConnection) url.openConnection();
connection.setConnectTimeout(HTTP_TIMEOUT_SECOND * 1000);
connection.setReadTimeout(HTTP_TIMEOUT_SECOND * 1000);
- return mapper.readValue(connection.getInputStream(), StorageInfo.class);
+
+ String response;
+ try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
+ String line;
+ StringBuilder sb = new StringBuilder();
+ while ((line = bufferedReader.readLine()) != null) {
+ sb.append(line);
+ }
+ response = sb.toString();
+ }
+
+ // For http v2, the response body for "/info" api changed from
+ // StorageInfo to StorageInfoV2.
+ // So we need to make it compatible with old api.
+ try {
+ return mapper.readValue(response, StorageInfo.class);
+ } catch (Exception e) {
+ // try new response body
+ return mapper.readValue(response, StorageInfoV2.class).data;
+ }
} finally {
if (connection != null) {
connection.disconnect();
diff --git a/fe/fe-core/src/main/java/org/apache/doris/persist/StorageInfoV2.java b/fe/fe-core/src/main/java/org/apache/doris/persist/StorageInfoV2.java
new file mode 100644
index 0000000..8f1bba7
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/persist/StorageInfoV2.java
@@ -0,0 +1,30 @@
+// 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.
+
+package org.apache.doris.persist;
+
+/**
+ * This class is wrapper of StorageInfo.
+ * Because for http v2, the response body of "/info" api changed to:
+ * {"msg":"success","code":0,"data":{"clusterID":1464655034,"imageSeq":809779,"editsSeq":0},"count":0}
+ */
+public class StorageInfoV2 {
+ public String msg;
+ public int code;
+ public StorageInfo data;
+ public int count;
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org