Skip to content

Commit

Permalink
sync code to update to 0.45.1-public
Browse files Browse the repository at this point in the history
Change-Id: Iae586734d640df5c5cb139d5c78e34561d3ee247
  • Loading branch information
Joseph1314 committed Sep 22, 2023
1 parent a0783cf commit 2de9b36
Show file tree
Hide file tree
Showing 16 changed files with 104 additions and 28 deletions.
4 changes: 2 additions & 2 deletions odps-console-auth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
</parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console-auth</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
<name>odps-console-auth</name>

<properties>
Expand Down
4 changes: 2 additions & 2 deletions odps-console-basic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
</parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console-basic</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
<name>odps-console-basic</name>
<url>http://odps.aliyun.com</url>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@
import java.io.InputStream;
import java.io.PrintStream;
import java.lang.Character.UnicodeBlock;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.URL;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.Formatter;
import java.util.Iterator;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -192,7 +196,7 @@ public static String getUserAgent() {
}
if (StringUtils.isNullOrEmpty(userIp)) {
try {
userIp = InetAddress.getLocalHost().getHostAddress();
userIp = getCurrentIp().getHostAddress();
} catch (UnknownHostException e) {
}
}
Expand Down Expand Up @@ -548,4 +552,25 @@ public static String makeTitle(List<Column> columns, Map<String, Integer> displa
}
return titleBuf.toString();
}

/**
* 该方法可以过滤掉本地地址、回环地址127.0.0.1、和ipv6地址
*/
private static InetAddress getCurrentIp() throws UnknownHostException {
try {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
NetworkInterface ni = networkInterfaces.nextElement();
Enumeration<InetAddress> nias = ni.getInetAddresses();
while (nias.hasMoreElements()) {
InetAddress ia = nias.nextElement();
if (!ia.isLinkLocalAddress() && !ia.isLoopbackAddress() && ia instanceof Inet4Address) {
return ia;
}
}
}
} catch (SocketException ignore) {
}
return InetAddress.getLocalHost();
}
}
4 changes: 2 additions & 2 deletions odps-console-cupid-public/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
<parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
</parent>
<artifactId>odps-console-cupid-public</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
<name>odps-console-cupid-public</name>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion odps-console-dist-public/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>odps-console</artifactId>
<groupId>com.aliyun.openservices.odps</groupId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
4 changes: 2 additions & 2 deletions odps-console-dship/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
</parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console-dship</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
<name>odps-console-dship</name>

<dependencies>
Expand Down
4 changes: 2 additions & 2 deletions odps-console-mr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
</parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console-mr</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
<name>odps-console-mr</name>

<properties>
Expand Down
4 changes: 2 additions & 2 deletions odps-console-public/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
</parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console-public</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
<name>odps-console-public</name>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.UUID;

import com.aliyun.odps.utils.StringUtils;

Expand All @@ -19,4 +20,7 @@ public static String longToDateTime(String time) {
ZoneId.systemDefault());
return dateTimeFormatter.format(Instant.ofEpochSecond(Long.parseLong(time)));
}
public static String getRandomName() {
return UUID.randomUUID().toString().replace("-", "");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
Expand All @@ -41,6 +40,8 @@
import com.aliyun.odps.OdpsException;
import com.aliyun.odps.Partition;
import com.aliyun.odps.PartitionSpec;
import com.aliyun.odps.StorageTierInfo;
import com.aliyun.odps.StorageTierInfo.StorageTier;
import com.aliyun.odps.Table;
import com.aliyun.odps.utils.StringUtils;
import com.aliyun.openservices.odps.console.ErrorCode;
Expand Down Expand Up @@ -111,7 +112,7 @@ public DescribeTableCommand(
ExecutionContext cxt,
Coordinate coordinate,
boolean isExtended
) {
) {
super(cmd, cxt);
this.coordinate = coordinate;
this.isExtended = isExtended;
Expand Down Expand Up @@ -180,6 +181,14 @@ private String getScreenDisplay(Table t, Partition meta) throws ODPSConsoleExcep
return getBasicScreenDisplay(t, meta) + getExtendedScreenDisplay(t, meta);
}

private String getSpace(int len) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < len; i++) {
sb.append(' ');
}
return sb.toString();
}

// port from task/sql_task/query_result_helper.cpp:PrintTableMeta
private String getBasicScreenDisplay(Table t, Partition meta) throws ODPSConsoleException {
StringWriter out = new StringWriter();
Expand Down Expand Up @@ -337,6 +346,7 @@ private String getExtendedScreenDisplay(Table t, Partition pt) throws ODPSConsol

StringWriter out = new StringWriter();
PrintWriter w = new PrintWriter(out);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

try {
if (pt != null) {
Expand Down Expand Up @@ -367,6 +377,18 @@ private String getExtendedScreenDisplay(Table t, Partition pt) throws ODPSConsol
if (isAcid2Table) {
appendAcidInfo(t, pt.getClusterInfo(), w);
}
// 具体分区 显示分层存储信息
if (pt.getStorageTierInfo() != null) {
if (pt.getStorageTierInfo().getStorageTier() != null) {
w.printf("| StorageTier: %-56s |\n",
pt.getStorageTierInfo().getStorageTier().getName());
}
Date lastModifiedTime = pt.getStorageTierInfo().getStorageLastModifiedTime();
if (lastModifiedTime != null) {
w.printf("| StorageTierLastModifiedTime: %-52s |\n", df.format(lastModifiedTime));
}
}

w.println(
"+------------------------------------------------------------------------------------+");
} else {
Expand Down Expand Up @@ -431,6 +453,31 @@ private String getExtendedScreenDisplay(Table t, Partition pt) throws ODPSConsol
if (isAcid2Table) {
appendAcidInfo(t, t.getClusterInfo(), w);
}
// storageTier 需要区分是分区表还是非分区表
if (t.isPartitioned()) { //分区表显示汇总
StorageTierInfo storageTierInfo = t.getStorageTierInfo();
if (storageTierInfo != null) {
for (StorageTier tier : StorageTier.values()) {
if (storageTierInfo.getStorageSize(tier) != null) {
w.printf("| %s:%s %-56d |\n", tier.getSizeName(),
getSpace(24 - tier.getSizeName().length()),
storageTierInfo.getStorageSize(tier));
}
}
}
} else { //非分区表只显示类型和修改时间
if (t.getStorageTierInfo() != null) {
if (t.getStorageTierInfo().getStorageTier() != null) {
w.printf("| StorageTier: %-56s |\n",
t.getStorageTierInfo().getStorageTier().getName());
}
Date lastModifiedTime = t.getStorageTierInfo().getStorageLastModifiedTime();
if (lastModifiedTime != null) {
w.printf("| StorageTierLastModifiedTime: %-52s |\n", df.format(lastModifiedTime));
}
}
}

w.println(
"+------------------------------------------------------------------------------------+");
}
Expand Down
4 changes: 2 additions & 2 deletions odps-console-resource/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
</parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console-resource</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
<name>odps-console-resource</name>

<dependencies>
Expand Down
4 changes: 2 additions & 2 deletions odps-console-sql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
</parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console-sql</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
<name>odps-console-sql</name>

<dependencies>
Expand Down
4 changes: 2 additions & 2 deletions odps-console-tunnel/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
</parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console-tunnel</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
<name>odps-console-tunnel</name>

<properties>
Expand Down
4 changes: 2 additions & 2 deletions odps-console-volume2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
</parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console-volume2</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
<name>odps-console-volume2</name>

<dependencies>
Expand Down
4 changes: 2 additions & 2 deletions odps-console-xflow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
</parent>
<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console-xflow</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
<name>odps-console-xflow</name>
<url>http://maven.apache.org</url>
<properties>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>com.aliyun.openservices.odps</groupId>
<artifactId>odps-console</artifactId>
<version>0.45.0-public</version>
<version>0.45.1-public</version>
<packaging>pom</packaging>

<name>odps-console</name>
Expand All @@ -35,7 +35,7 @@
</licenses>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<odps.sdk.version>0.45.2-public</odps.sdk.version>
<odps.sdk.version>0.45.3-public</odps.sdk.version>
<hadoop.version>3.3.3</hadoop.version>
</properties>

Expand Down

0 comments on commit 2de9b36

Please sign in to comment.